summaryrefslogtreecommitdiff
path: root/src/AST
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-09-22 23:16:27 +0200
committerTom Smeding <tom@tomsmeding.com>2024-09-22 23:16:27 +0200
commit76917de6d801e3667cdf3f1bbbb5c2bceabdecb6 (patch)
tree5be0ab5efb17077738d2acd51db95e5ce8b92b58 /src/AST
parent7bc10684870e2249efbdcdddb4950f52d8527699 (diff)
Add some missing cases
Diffstat (limited to 'src/AST')
-rw-r--r--src/AST/Count.hs3
-rw-r--r--src/AST/Pretty.hs15
2 files changed, 18 insertions, 0 deletions
diff --git a/src/AST/Count.hs b/src/AST/Count.hs
index 40a46f6..ad68685 100644
--- a/src/AST/Count.hs
+++ b/src/AST/Count.hs
@@ -110,6 +110,9 @@ occCountGeneral onehot unpush alter many = go WId
EInl _ _ e -> re e
EInr _ _ e -> re e
ECase _ e a b -> re e <> (re1 a `alter` re1 b)
+ ENothing _ _ -> mempty
+ EJust _ e -> re e
+ EMaybe _ a b e -> re a <> re1 b <> re e
EConstArr{} -> mempty
EBuild1 _ a b -> re a <> many (re1 b)
EBuild _ _ a b -> re a <> many (re1 b)
diff --git a/src/AST/Pretty.hs b/src/AST/Pretty.hs
index f5e681a..7f60db1 100644
--- a/src/AST/Pretty.hs
+++ b/src/AST/Pretty.hs
@@ -92,6 +92,21 @@ ppExpr' d val = \case
showString "case " . e' . showString (" of { Inl " ++ name1 ++ " -> ") . a'
. showString (" ; Inr " ++ name2 ++ " -> ") . b' . showString " }"
+ ENothing _ _ -> return $ showString "nothing"
+
+ EJust _ e -> do
+ e' <- ppExpr' 11 val e
+ return $ showParen (d > 10) $ showString "Just " . e'
+
+ EMaybe _ a b e -> do
+ let STMaybe t = typeOf e
+ a' <- ppExpr' 11 val a
+ name <- genNameIfUsedIn t IZ b
+ b' <- ppExpr' 11 (Const name `SCons` val) b
+ e' <- ppExpr' 11 val e
+ return $ showParen (d > 10) $
+ showString "maybe " . a' . showString " " . b' . showString " " . e'
+
EConstArr _ _ ty v
| Dict <- scalRepIsShow ty -> return $ showsPrec d v