@@ -186,27 +186,29 @@ getFixedInType i _ _ _ = []
186getFlexInType i env ps (Bind n (Pi _ t _) sc)
186getFlexInType i env ps (Bind n (Pi _ t _) sc)
187 = nub $ (if (not (n `elem` ps)) then getFlexInType i env ps t else []) ++
187 = nub $ (if (not (n `elem` ps)) then getFlexInType i env ps t else []) ++
188 getFlexInType i (n : env) ps (instantiate (P Bound n t) sc)
188 getFlexInType i (n : env) ps (instantiate (P Bound n t) sc)
189getFlexInType i env ps tm@(App _ f a)
190getFlexInType i env ps tm@(App _ f a)
190− | (P _ tn _, args) <- unApply tm
191+ | (P nt tn _, args) <- unApply tm, nt /= Bound
191 = case lookupCtxt tn (idris_datatypes i) of
192 = case lookupCtxt tn (idris_datatypes i) of
192 [t] -> nub $ paramNames args env [x | x <- [0..length args],
193 [t] -> nub $ paramNames args env [x | x <- [0..length args],
193 not (x `elem` param_pos t)]
194 not (x `elem` param_pos t)]
194 ++ getFlexInType i env ps f ++
195 ++ getFlexInType i env ps f ++
195 getFlexInType i env ps a
196 getFlexInType i env ps a
196− [] -> let ppos = case lookupCtxt tn (idris_fninfo i) of
197+ [] -> let ppos = case lookupCtxtName tn (idris_fninfo i) of
197− [fi] -> fn_params fi
198+ [fi] -> fn_params (snd fi)
198− [] -> [] in
199+ [] -> []
200+ xs -> error ("Too much function info: " ++ show xs)
199− nub $ paramNames args env [x | x <- [0..length args],
201+ in nub $ paramNames args env [x | x <- [0..length args],
200− not (x `elem` ppos)]
202+ not (x `elem` ppos)]
201− ++ getFlexInType i env ps f ++
203+ ++ getFlexInType i env ps f ++
202− getFlexInType i env ps a
204+ getFlexInType i env ps a
203 | otherwise = nub $ getFlexInType i env ps f ++
205 | otherwise = nub $ getFlexInType i env ps f ++
204 getFlexInType i env ps a
206 getFlexInType i env ps a
205getFlexInType i _ _ _ = []
207getFlexInType i _ _ _ = []
207−-- Treat a name as a parameter if it appears in parameter positions in
209+-- | Treat a name as a parameter if it appears in parameter positions in
208-- types, and never in a non-parameter position in a (non-param) argument type.
210-- types, and never in a non-parameter position in a (non-param) argument type.
209−
211+getParamsInType :: IState -> [Name] -> [PArg] -> Type -> [Name]
210getParamsInType i env ps t = let fix = getFixedInType i env ps t
212getParamsInType i env ps t = let fix = getFixedInType i env ps t
211 flex = getFlexInType i env fix t in
213 flex = getFlexInType i env fix t in
212 [x | x <- fix, not (x `elem` flex)]
214 [x | x <- fix, not (x `elem` flex)]