@@ -196,7 +196,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
196196 Nothing -> -- local variable, go for it
197197 return True
198198 TType _ -> return True
199− _ -> fail "Not a data type"
199+ _ -> typeNotSearchable ty
200200
201201 conReady :: [Term] -> Name -> ElabD Bool
202202 conReady as n
@@ -282,8 +282,8 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
282282 -- since that's part of the point...)
283283 $ checkConstructor ist others
284284 tryCons d locs tys (others ++ getFn d fn)
285− Nothing -> fail "Not a data type"
286− _ -> fail "Not a data type"
285+ Nothing -> typeNotSearchable t
286+ _ -> typeNotSearchable t
287287
288288 -- if there are local variables which have a function type, try
289289 -- applying them too
@@ -326,11 +326,20 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
326326 let newhs = filter (\ (x, y) -> not x) (zip (map fst imps) args)
327327 mapM_ (\ (_, h) -> do focus h
328328 aty <- goal
329− psRec True d locs tys) newhs
329+ psRec True d locs tys) newhs
330330 solve
331331
332332 isImp (PImp p _ _ _ _) = (True, p)
333− isImp arg = (False, priority arg)
333+ isImp arg = (False, priority arg)
334+
335+ typeNotSearchable ty =
336+ lift $ tfail $ FancyMsg $
337+ [TextPart "Attempted to find an element of type",
338+ TermPart ty,
339+ TextPart "using proof search, but proof search only works on datatypes with constructors."] ++
340+ case ty of
341+ (Bind _ (Pi _ _ _) _) -> [TextPart "In particular, function types are not supported."]
342+ _ -> []
334343
335344-- In interactive mode, only search for things if there is some
336345-- index to help pick a relevant constructor