Created
January 23, 2014 15:34
-
-
Save david-christiansen/8580625 to your computer and use it in GitHub Desktop.
Error reflection now supports specific function arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Language.Reflection.Errors | |
import Language.Reflection.Utils | |
%language ErrorReflection | |
total | |
cadr : (xs : List a) | |
-> {auto cons1 : isCons xs = True} | |
-> {auto cons2 : isCons (tail xs cons1) = True} | |
-> a | |
cadr (x :: (y :: _)) {cons1=refl} {cons2=refl} = y | |
cadr (x :: []) {cons1=refl} {cons2=refl} impossible | |
extractList : TT -> Maybe TT | |
extractList (App (App reflCon (App isCons lst)) _) = Just lst | |
extractList _ = Nothing | |
total | |
has2elts : Err -> Maybe (List ErrorReportPart) | |
has2elts (CantSolveGoal tm _) = do lst <- extractList tm | |
return [ TextPart "Could not prove that" | |
, TermPart lst | |
, TextPart "has at least two elements." | |
] | |
has2elts e = Just [TextPart (show e)] | |
%error_handlers cadr cons1 has2elts | |
%error_handlers cadr cons2 has2elts | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*FunErrTest> cadr [] | |
Could not prove that [] has at least two elements. | |
Original error: | |
Can't solve goal | |
isCons [] = True | |
*FunErrTest> \ xs : List Int => cadr xs | |
Could not prove that xs has at least two elements. | |
Original error: | |
Can't solve goal | |
isCons xs = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment