@@ -14,36 +14,20 @@ cadr : (xs : List a)
1414cadr (x :: (y :: _)) {cons1=refl} {cons2=refl} = y
1515cadr (x :: []) {cons1=refl} {cons2=refl} impossible
1616
17−total
18−eltsErr : TT -> TT -> Maybe (List ErrorReportPart)
19−eltsErr (P (DCon _ _) (NS (UN "False") _) _) (P (DCon _ _) (NS (UN "True") _) _) =
20− Just [ NamePart (NS (UN "cadr") ["FunErrTest"])
21− , TextPart "requires that its argument contain at least two elements."
22− ]
23−eltsErr (P (DCon _ _) (NS (UN "True") _) _) (App (App isCons ty) xs) =
24− Just [ NamePart (NS (UN "cadr") ["FunErrTest"])
25− , TextPart "requires that its argument contain at least two elements."
26− , TextPart "This fails because: "
27− , SubReport [ TextPart "There is no proof that"
28− , TermPart xs
29− , TextPart "is non-empty."
30− ]
31− ]
32−eltsErr _ _ = Nothing
17+extractList : TT -> Maybe TT
18+extractList (App (App reflCon (App isCons lst)) _) = Just lst
19+extractList _ = Nothing
20+
3321
3422total
3523has2elts : Err -> Maybe (List ErrorReportPart)
36−has2elts (CantUnify _ tm1 tm2 e _ _) = eltsErr tm1 tm2 <|> has2elts e
24+has2elts (CantSolveGoal tm _) = do lst <- extractList tm
25+ return [ TextPart "Could not prove that"
26+ , TermPart lst
27+ , TextPart "has at least two elements."
28+ ]
3729has2elts e = Just [TextPart (show e)]
3830
3931%error_handlers cadr cons1 has2elts
4032%error_handlers cadr cons2 has2elts
4133
42−problem1 : List a -> a
43−problem1 xs = cadr xs
44−
45−problem2 : Int
46−problem2 = cadr [1]
47−
48−problem3 : Int
49−problem3 = cadr []