pattern matching works? have to test more

This commit is contained in:
sebastianselander 2023-03-03 11:46:54 +01:00
parent 7656b46e3f
commit 03d7080396
5 changed files with 76 additions and 34 deletions

View file

@ -127,6 +127,17 @@ instance Print Exp where
, doc $ showString "."
, prt 0 e
]
ECase t exp injs -> prPrec i 0 (concatD [doc (showString "case"), prt 0 exp, doc (showString "of"), doc (showString "{"), prt 0 injs, doc (showString "}"), doc (showString ":"), prt 0 t])
instance Print Inj where
prt i = \case
Inj (init,t) exp -> prPrec i 0 (concatD [prt 0 init, doc (showString ":"), prt 0 t, doc (showString "=>"), prt 0 exp])
instance Print [Inj] where
prt _ [] = concatD []
prt _ [x] = concatD [prt 0 x]
prt _ (x:xs) = concatD [prt 0 x, doc (showString ";"), prt 0 xs]