diff --git a/ast.hs b/ast.hs index 510785c..08fa63f 100644 --- a/ast.hs +++ b/ast.hs @@ -33,6 +33,7 @@ data AST = Add AST AST data Pattern = VarP String | IntP Integer | StrP String + | BoolP Bool | UnitP | ConsP Pattern Pattern | TupleP [Pattern] diff --git a/interp.hs b/interp.hs index b50e17f..eb55673 100644 --- a/interp.hs +++ b/interp.hs @@ -324,6 +324,10 @@ patternBindings (IntP n) (IntV v) | otherwise = Nothing patternBindings (IntP n) _ = Nothing +patternBindings (BoolP b) (BoolV v) + | v == b = Just M.empty + | otherwise = Nothing + patternBindings UnitP UnitV = Just M.empty patternBindings UnitP _ = Nothing diff --git a/parser.hs b/parser.hs index d858723..31c08d4 100644 --- a/parser.hs +++ b/parser.hs @@ -40,6 +40,7 @@ pattern :: Pattern = pattern "::" pattern { ConsP $1 $2 } / "[" patternlist "]" / patterntuple + / "true" { BoolP True } / "false" { BoolP False } / identifier { VarP $1 } / stringlit { StrP $1 } / integer { IntP $1 }