@@ -17,7 +17,7 @@ data SC = Case Name [CaseAlt] -- invariant: lowest tags first
17 | ProjCase Term [CaseAlt] -- special case for projections
17 | ProjCase Term [CaseAlt] -- special case for projections
18 | STerm Term
18 | STerm Term
19 | UnmatchedCase String -- error message
19 | UnmatchedCase String -- error message
20− deriving (Show, Eq, Ord)
20+ deriving (Eq, Ord)
22deriving instance Binary SC
22deriving instance Binary SC
@@ -30,6 +30,27 @@ data CaseAlt = ConCase Name Int [Name] SC
30deriving instance Binary CaseAlt
30deriving instance Binary CaseAlt
33+instance Show SC where
36+ show' i (Case n alts) = "case " ++ show n ++ " of\n" ++ indent i ++
37+ showSep ("\n" ++ indent i) (map (showA i) alts)
38+ show' i (ProjCase tm alts) = "case " ++ show tm ++ " of " ++
39+ showSep ("\n" ++ indent i) (map (showA i) alts)
40+ show' i (STerm tm) = show tm
41+ show' i (UnmatchedCase str) = "error " ++ show str
43+ indent i = concat $ take i (repeat " ")
45+ showA i (ConCase n t args sc)
46+ = show n ++ "(" ++ showSep (", ") (map show args) ++ ") => "
48+ showA i (ConstCase t sc)
49+ = show t ++ " => " ++ show' (i+1) sc
50+ showA i (DefaultCase sc)
51+ = "_ => " ++ show' (i+1) sc
33type CaseTree = SC
54type CaseTree = SC
34type Clause = ([Pat], (Term, Term))
55type Clause = ([Pat], (Term, Term))
35type CS = ([Term], Int)
56type CS = ([Term], Int)