on master help sign in
Better error message for cast failure
commit89c19be300d89a98f5ed62a9121f11f213f2723a authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSun 7 Jun 2015, 19:05 (11 years ago) parentc882154
1 file changed+18
libs/prelude/Prelude.idr+18
libs/prelude/Prelude.idr+18
@@ -457,3 +457,21 @@ readFile fn = do h <- openFile fn Read
457457 if not x then do l <- fread h
458458 readFile' h (contents ++ l)
459459 else return contents
460+
461+------- Some error rewriting
462+
463+%language ErrorReflection
464+
465+cast_part : TT -> ErrorReportPart
466+cast_part (P Bound n t) = TextPart "unknown type"
467+cast_part x = TermPart x
468+
469+%error_handler
470+cast_error : Err -> Maybe (List ErrorReportPart)
471+cast_error (CantResolve `(Cast ~x ~y))
472+ = Just [TextPart "Can't cast from",
473+ cast_part x,
474+ TextPart "to",
475+ cast_part y]
476+cast_error _ = Nothing
477+