@@ -196,7 +196,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
196 Nothing -> -- local variable, go for it
196 Nothing -> -- local variable, go for it
197 return True
197 return True
198 TType _ -> return True
198 TType _ -> return True
199− _ -> fail "Not a data type"
199+ _ -> typeNotSearchable ty
201 conReady :: [Term] -> Name -> ElabD Bool
201 conReady :: [Term] -> Name -> ElabD Bool
202 conReady as n
202 conReady as n
@@ -282,8 +282,8 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
282 -- since that's part of the point...)
282 -- since that's part of the point...)
283 $ checkConstructor ist others
283 $ checkConstructor ist others
284 tryCons d locs tys (others ++ getFn d fn)
284 tryCons d locs tys (others ++ getFn d fn)
285− Nothing -> fail "Not a data type"
285+ Nothing -> typeNotSearchable t
286− _ -> fail "Not a data type"
286+ _ -> typeNotSearchable t
288 -- if there are local variables which have a function type, try
288 -- if there are local variables which have a function type, try
289 -- applying them too
289 -- applying them too
@@ -326,11 +326,20 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
326 let newhs = filter (\ (x, y) -> not x) (zip (map fst imps) args)
326 let newhs = filter (\ (x, y) -> not x) (zip (map fst imps) args)
327 mapM_ (\ (_, h) -> do focus h
327 mapM_ (\ (_, h) -> do focus h
328 aty <- goal
328 aty <- goal
329− psRec True d locs tys) newhs
329+ psRec True d locs tys) newhs
332 isImp (PImp p _ _ _ _) = (True, p)
332 isImp (PImp p _ _ _ _) = (True, p)
333− isImp arg = (False, priority arg)
333+ isImp arg = (False, priority arg)
335+ typeNotSearchable ty =
336+ lift $ tfail $ FancyMsg $
337+ [TextPart "Attempted to find an element of type",
339+ TextPart "using proof search, but proof search only works on datatypes with constructors."] ++
341+ (Bind _ (Pi _ _ _) _) -> [TextPart "In particular, function types are not supported."]
335-- In interactive mode, only search for things if there is some
344-- In interactive mode, only search for things if there is some
336-- index to help pick a relevant constructor
345-- index to help pick a relevant constructor