@@ -48,13 +48,13 @@ trivialHoles psnames ok elab ist
48 then try' (elab (PRef (fileFC "prf") [] x))
48 then try' (elab (PRef (fileFC "prf") [] x))
49 (tryAll xs) True
49 (tryAll xs) True
50 else tryAll xs
50 else tryAll xs
52 holesOK hs ap@(App _ _ _)
52 holesOK hs ap@(App _ _ _)
53 | (P _ n _, args) <- unApply ap
53 | (P _ n _, args) <- unApply ap
54 = holeArgsOK hs n 0 args
54 = holeArgsOK hs n 0 args
55 holesOK hs (App _ f a) = holesOK hs f && holesOK hs a
55 holesOK hs (App _ f a) = holesOK hs f && holesOK hs a
56 holesOK hs (P _ n _) = not (n `elem` hs)
56 holesOK hs (P _ n _) = not (n `elem` hs)
57− holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
57+ holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
58 holesOK hs sc
58 holesOK hs sc
59 holesOK hs _ = True
59 holesOK hs _ = True
@@ -85,8 +85,8 @@ trivialTCs ok elab ist
85 then try' (elab (PRef (fileFC "prf") [] x))
85 then try' (elab (PRef (fileFC "prf") [] x))
86 (tryAll xs) True
86 (tryAll xs) True
87 else tryAll xs
87 else tryAll xs
89− tcArg env ty
89+ tcArg env ty
90 | (P _ n _, args) <- unApply (getRetTy (normalise (tt_ctxt ist) env ty))
90 | (P _ n _, args) <- unApply (getRetTy (normalise (tt_ctxt ist) env ty))
91 = case lookupCtxtExact n (idris_classes ist) of
91 = case lookupCtxtExact n (idris_classes ist) of
92 Just _ -> True
92 Just _ -> True
@@ -98,7 +98,7 @@ trivialTCs ok elab ist
98 = holeArgsOK hs n 0 args
98 = holeArgsOK hs n 0 args
99 holesOK hs (App _ f a) = holesOK hs f && holesOK hs a
99 holesOK hs (App _ f a) = holesOK hs f && holesOK hs a
100 holesOK hs (P _ n _) = not (n `elem` hs)
100 holesOK hs (P _ n _) = not (n `elem` hs)
101− holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
101+ holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
102 holesOK hs sc
102 holesOK hs sc
103 holesOK hs _ = True
103 holesOK hs _ = True
@@ -111,16 +111,16 @@ cantSolveGoal :: ElabD a
111cantSolveGoal = do g <- goal
111cantSolveGoal = do g <- goal
112 env <- get_env
112 env <- get_env
113 lift $ tfail $
113 lift $ tfail $
114− CantSolveGoal g (map (\(n,b) -> (n, binderTy b)) env)
114+ CantSolveGoal g (map (\(n,b) -> (n, binderTy b)) env)
116−proofSearch :: Bool -> -- recursive search (False for 'refine')
116+proofSearch :: Bool -> -- recursive search (False for 'refine')
117 Bool -> -- invoked from a tactic proof. If so, making
117 Bool -> -- invoked from a tactic proof. If so, making
118 -- new metavariables is meaningless, and there shoudl
118 -- new metavariables is meaningless, and there shoudl
119 -- be an error reported instead.
119 -- be an error reported instead.
120 Bool -> -- ambiguity ok
120 Bool -> -- ambiguity ok
121 Bool -> -- defer on failure
121 Bool -> -- defer on failure
122 Int -> -- maximum depth
122 Int -> -- maximum depth
123− (PTerm -> ElabD ()) -> Maybe Name -> Name ->
123+ (PTerm -> ElabD ()) -> Maybe Name -> Name ->
124 [Name] ->
124 [Name] ->
125 [Name] ->
125 [Name] ->
126 IState -> ElabD ()
126 IState -> ElabD ()
@@ -131,7 +131,7 @@ proofSearch False fromProver ambigok deferonfail depth elab _ nroot psnames [fn]
131 tryAllFns all_imps
131 tryAllFns all_imps
133 -- if nothing worked, make a new metavariable
133 -- if nothing worked, make a new metavariable
134− tryAllFns [] | fromProver = cantSolveGoal
134+ tryAllFns [] | fromProver = cantSolveGoal
135 tryAllFns [] = do attack; defer [] nroot; solve
135 tryAllFns [] = do attack; defer [] nroot; solve
136 tryAllFns (f : fs) = try' (tryFn f) (tryAllFns fs) True
136 tryAllFns (f : fs) = try' (tryFn f) (tryAllFns fs) True
@@ -142,20 +142,20 @@ proofSearch False fromProver ambigok deferonfail depth elab _ nroot psnames [fn]
142 (match_apply (Var f) imps) True
142 (match_apply (Var f) imps) True
143 ps' <- get_probs
143 ps' <- get_probs
144-- when (length ps < length ps') $ fail "Can't apply constructor"
144-- when (length ps < length ps') $ fail "Can't apply constructor"
145− -- Make metavariables for new holes
145+ -- Make metavariables for new holes
146 hs' <- get_holes
146 hs' <- get_holes
147 ptm <- get_term
147 ptm <- get_term
148 if fromProver then cantSolveGoal
148 if fromProver then cantSolveGoal
150 mapM_ (\ h -> do focus h
150 mapM_ (\ h -> do focus h
151− attack; defer [] nroot; solve)
151+ attack; defer [] nroot; solve)
152 (hs' \\ hs)
152 (hs' \\ hs)
153-- (filter (\ (x, y) -> not x) (zip (map fst imps) args))
153-- (filter (\ (x, y) -> not x) (zip (map fst imps) args))
156 isImp (PImp p _ _ _ _) = (True, p)
156 isImp (PImp p _ _ _ _) = (True, p)
157 isImp arg = (True, priority arg) -- try to get all of them by unification
157 isImp arg = (True, priority arg) -- try to get all of them by unification
158−proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hints ist
158+proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hints ist
159 = do compute
159 = do compute
160 ty <- goal
160 ty <- goal
161 hs <- get_holes
161 hs <- get_holes
@@ -172,7 +172,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
172 (autoArg (sUN "auto"))
172 (autoArg (sUN "auto"))
173 else autoArg (sUN "auto") -- not enough info in the type yet
173 else autoArg (sUN "auto") -- not enough info in the type yet
175− findInferredTy (t : _) = elab (delab ist (toUN t))
175+ findInferredTy (t : _) = elab (delab ist (toUN t))
177 cantsolve (InternalMsg _) = True
177 cantsolve (InternalMsg _) = True
178 cantsolve (CantSolveGoal _ _) = True
178 cantsolve (CantSolveGoal _ _) = True
@@ -185,12 +185,12 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
185 conArgsOK ty
185 conArgsOK ty
186 = let (f, as) = unApply ty in
186 = let (f, as) = unApply ty in
187 case f of
187 case f of
188− P _ n _ ->
188+ P _ n _ ->
189 let autohints = case lookupCtxtExact n (idris_autohints ist) of
189 let autohints = case lookupCtxtExact n (idris_autohints ist) of
190 Nothing -> []
190 Nothing -> []
191 Just hs -> hs in
191 Just hs -> hs in
192 case lookupCtxtExact n (idris_datatypes ist) of
192 case lookupCtxtExact n (idris_datatypes ist) of
193− Just t -> do rs <- mapM (conReady as)
193+ Just t -> do rs <- mapM (conReady as)
194 (autohints ++ con_names t)
194 (autohints ++ con_names t)
195 return (and rs)
195 return (and rs)
196 Nothing -> -- local variable, go for it
196 Nothing -> -- local variable, go for it
@@ -199,7 +199,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
199 _ -> typeNotSearchable ty
199 _ -> typeNotSearchable ty
201 conReady :: [Term] -> Name -> ElabD Bool
201 conReady :: [Term] -> Name -> ElabD Bool
202− conReady as n
202+ conReady as n
203 = case lookupTyExact n (tt_ctxt ist) of
203 = case lookupTyExact n (tt_ctxt ist) of
204 Just ty -> do let (_, cs) = unApply (getRetTy ty)
204 Just ty -> do let (_, cs) = unApply (getRetTy ty)
205 -- if any metavariables in 'as' correspond to
205 -- if any metavariables in 'as' correspond to
@@ -223,7 +223,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
223 inHS hs (P _ n _) = n `elem` hs
223 inHS hs (P _ n _) = n `elem` hs
224 isHS _ _ = False
224 isHS _ _ = False
226− toUN t@(P nt (MN i n) ty)
226+ toUN t@(P nt (MN i n) ty)
227 | ('_':xs) <- str n = t
227 | ('_':xs) <- str n = t
228 | otherwise = P nt (UN n) ty
228 | otherwise = P nt (UN n) ty
229 toUN (App s f a) = App s (toUN f) (toUN a)
229 toUN (App s f a) = App s (toUN f) (toUN a)
@@ -239,7 +239,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
239 psRec :: Bool -> Int -> [Name] -> S.Set Type -> ElabD ()
239 psRec :: Bool -> Int -> [Name] -> S.Set Type -> ElabD ()
240 psRec _ 0 locs tys | fromProver = cantSolveGoal
240 psRec _ 0 locs tys | fromProver = cantSolveGoal
241 psRec rec 0 locs tys = do attack; defer [] nroot; solve --fail "Maximum depth reached"
241 psRec rec 0 locs tys = do attack; defer [] nroot; solve --fail "Maximum depth reached"
242− psRec False d locs tys = tryCons d locs tys hints
242+ psRec False d locs tys = tryCons d locs tys hints
243 psRec True d locs tys
243 psRec True d locs tys
244 = do compute
244 = do compute
245 ty <- goal
245 ty <- goal
@@ -248,11 +248,11 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
248 try' (try' (trivialHoles psnames [] elab ist)
248 try' (try' (trivialHoles psnames [] elab ist)
249 (resolveTC False False 20 ty nroot elab ist)
249 (resolveTC False False 20 ty nroot elab ist)
251− (try' (try' (resolveByCon (d - 1) locs tys')
251+ (try' (try' (resolveByCon (d - 1) locs tys')
252 (resolveByLocals (d - 1) locs tys')
252 (resolveByLocals (d - 1) locs tys')
254 -- if all else fails, make a new metavariable
254 -- if all else fails, make a new metavariable
255− (if fromProver
255+ (if fromProver
256 then fail "cantSolveGoal"
256 then fail "cantSolveGoal"
257 else do attack; defer [] nroot; solve) True) True
257 else do attack; defer [] nroot; solve) True) True
@@ -269,7 +269,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
269 = do t <- goal
269 = do t <- goal
270 let (f, _) = unApply t
270 let (f, _) = unApply t
271 case f of
271 case f of
272− P _ n _ ->
272+ P _ n _ ->
273 do let autohints = case lookupCtxtExact n (idris_autohints ist) of
273 do let autohints = case lookupCtxtExact n (idris_autohints ist) of
274 Nothing -> []
274 Nothing -> []
275 Just hs -> hs
275 Just hs -> hs
@@ -292,26 +292,26 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
292 tryLocals d locs tys env
292 tryLocals d locs tys env
294 tryLocals d locs tys [] = fail "Locals failed"
294 tryLocals d locs tys [] = fail "Locals failed"
295− tryLocals d locs tys ((x, t) : xs)
295+ tryLocals d locs tys ((x, t) : xs)
296 | x `elem` locs || x `notElem` psnames = tryLocals d locs tys xs
296 | x `elem` locs || x `notElem` psnames = tryLocals d locs tys xs
297− | otherwise = try' (tryLocal d (x : locs) tys x t)
297+ | otherwise = try' (tryLocal d (x : locs) tys x t)
298 (tryLocals d locs tys xs) True
298 (tryLocals d locs tys xs) True
300 tryCons d locs tys [] = fail "Constructors failed"
300 tryCons d locs tys [] = fail "Constructors failed"
301− tryCons d locs tys (c : cs)
301+ tryCons d locs tys (c : cs)
302 = try' (tryCon d locs tys c) (tryCons d locs tys cs) True
302 = try' (tryCon d locs tys c) (tryCons d locs tys cs) True
304− tryLocal d locs tys n t
304+ tryLocal d locs tys n t
305 = do let a = getPArity (delab ist (binderTy t))
305 = do let a = getPArity (delab ist (binderTy t))
306 tryLocalArg d locs tys n a
306 tryLocalArg d locs tys n a
308 tryLocalArg d locs tys n 0 = elab (PRef (fileFC "prf") [] n)
308 tryLocalArg d locs tys n 0 = elab (PRef (fileFC "prf") [] n)
309− tryLocalArg d locs tys n i
309+ tryLocalArg d locs tys n i
310 = simple_app False (tryLocalArg d locs tys n (i - 1))
310 = simple_app False (tryLocalArg d locs tys n (i - 1))
311 (psRec True d locs tys) "proof search local apply"
311 (psRec True d locs tys) "proof search local apply"
313 -- Like type class resolution, but searching with constructors
313 -- Like type class resolution, but searching with constructors
314− tryCon d locs tys n =
314+ tryCon d locs tys n =
315 do ty <- goal
315 do ty <- goal
316 let imps = case lookupCtxtExact n (idris_implicits ist) of
316 let imps = case lookupCtxtExact n (idris_implicits ist) of
317 Nothing -> []
317 Nothing -> []
@@ -341,7 +341,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
341 (Bind _ (Pi _ _ _) _) -> [TextPart "In particular, function types are not supported."]
341 (Bind _ (Pi _ _ _) _) -> [TextPart "In particular, function types are not supported."]
344−-- In interactive mode, only search for things if there is some
344+-- In interactive mode, only search for things if there is some
345-- index to help pick a relevant constructor
345-- index to help pick a relevant constructor
346checkConstructor :: IState -> [Name] -> ElabD ()
346checkConstructor :: IState -> [Name] -> ElabD ()
347checkConstructor ist [] = return ()
347checkConstructor ist [] = return ()
@@ -397,7 +397,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
399 traceWhen ulog ("Resolving class " ++ show g ++ "\nin" ++ show env ++ "\n" ++ show okholes) $
399 traceWhen ulog ("Resolving class " ++ show g ++ "\nin" ++ show env ++ "\n" ++ show okholes) $
400− try' (trivialTCs okholes elab ist)
400+ try' (trivialTCs okholes elab ist)
401 (do addDefault t tc ttypes
401 (do addDefault t tc ttypes
402 let stk = map fst (filter snd $ elab_stack ist)
402 let stk = map fst (filter snd $ elab_stack ist)
403 let insts = findInstances ist t
403 let insts = findInstances ist t
@@ -432,7 +432,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
432 tcDetArgsOK _ _ _ [] = Just []
432 tcDetArgsOK _ _ _ [] = Just []
434 isMeta :: [Name] -> Term -> Bool
434 isMeta :: [Name] -> Term -> Bool
435− isMeta ns (P _ n _) = n `elem` ns
435+ isMeta ns (P _ n _) = n `elem` ns
436 isMeta _ _ = False
436 isMeta _ _ = False
438 notHole hs (P _ n _, c)
438 notHole hs (P _ n _, c)
@@ -449,7 +449,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
449 chaser (NS n _) = chaser n
449 chaser (NS n _) = chaser n
450 chaser _ = False
450 chaser _ = False
452− numclass = sNS (sUN "Num") ["Classes","Prelude"]
452+ numclass = sNS (sUN "Num") ["Interfaces","Prelude"]
454 addDefault t num@(P _ nc _) [P Bound a _] | nc == numclass && defaultOn
454 addDefault t num@(P _ nc _) [P Bound a _] | nc == numclass && defaultOn
455 = do focus a
455 = do focus a
@@ -530,5 +530,3 @@ findInstances ist t
530 where accessible n = case lookupDefAccExact n False (tt_ctxt ist) of
530 where accessible n = case lookupDefAccExact n False (tt_ctxt ist) of
531 Just (_, Hidden) -> False
531 Just (_, Hidden) -> False
532 _ -> True
532 _ -> True