@@ -16,6 +16,7 @@ import Control.Applicative hiding (Const)
1616import Control.Monad.State
1717import Control.Monad
1818import Data.List
19+import Data.Maybe
1920import qualified Data.Traversable as Traversable
2021
2122import Debug.Trace
@@ -211,6 +212,24 @@ getParamsInType i env ps t = let fix = getFixedInType i env ps t
211212 flex = getFlexInType i env fix t in
212213 [x | x <- fix, not (x `elem` flex)]
213214
215+getTCinj i (Bind n (Pi _ t _) sc)
216+ = getTCinj i t ++ getTCinj i (instantiate (P Bound n t) sc)
217+getTCinj i ap@(App _ f a)
218+ | (P _ n _, args) <- unApply ap,
219+ isTCName n = mapMaybe getInjName args
220+ | otherwise = []
221+ where
222+ isTCName n = case lookupCtxtExact n (idris_classes i) of
223+ Just _ -> True
224+ _ -> False
225+ getInjName t | (P _ x _, _) <- unApply t = Just x
226+ | otherwise = Nothing
227+getTCinj _ _ = []
228+
229+getTCParamsInType :: IState -> [Name] -> [PArg] -> Type -> [Name]
230+getTCParamsInType i env ps t = let params = getParamsInType i env ps t
231+ tcs = nub $ getTCinj i t in
232+ filter (flip elem tcs) params
214233paramNames args env [] = []
215234paramNames args env (p : ps)
216235 | length args > p = case args!!p of