forked from GitHub/gf-core
Introduce an explicit error value in the Term type
This makes it easier to treat run-time errors (e.g. caused by calls to Predef.error) in a way that is more typical for a lazy functional language.
This commit is contained in:
@@ -161,7 +161,7 @@ data Term =
|
||||
|
||||
| Alts Term [(Term, Term)] -- ^ alternatives by prefix: @pre {t ; s\/c ; ...}@
|
||||
| Strs [Term] -- ^ conditioning prefix strings: @strs {s ; ...}@
|
||||
|
||||
| Error String -- ^ error values returned by Predef.error
|
||||
deriving (Show, Eq, Ord)
|
||||
|
||||
data Patt =
|
||||
|
||||
@@ -192,6 +192,7 @@ ppTerm q d (Typed e t) = char '<' <> ppTerm q 0 e <+> colon <+> ppTerm q 0 t <>
|
||||
ppTerm q d (ImplArg e) = braces (ppTerm q 0 e)
|
||||
ppTerm q d (ELincat cat t) = prec d 4 (text "lincat" <+> ppIdent cat <+> ppTerm q 5 t)
|
||||
ppTerm q d (ELin cat t) = prec d 4 (text "lin" <+> ppIdent cat <+> ppTerm q 5 t)
|
||||
ppTerm q d (Error s) = prec d 4 (text "Predef.error" <+> str s)
|
||||
|
||||
ppEquation q (ps,e) = hcat (map (ppPatt q 2) ps) <+> text "->" <+> ppTerm q 0 e
|
||||
|
||||
|
||||
Reference in New Issue
Block a user