From 243f4f5b58014159be0c4dd7b0fc5c0a8021fd3c Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 23 May 2020 11:40:06 +0200 Subject: Don't parse Constructors as variables --- src/Haskell/AST.hs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Haskell/AST.hs') diff --git a/src/Haskell/AST.hs b/src/Haskell/AST.hs index f8b5c72..072fd97 100644 --- a/src/Haskell/AST.hs +++ b/src/Haskell/AST.hs @@ -22,6 +22,7 @@ data Def = Def Name Expr data Expr = App Expr [Expr] | Ref Name + | Con Name | Num Integer | Tup [Expr] | Lam [Name] Expr @@ -71,6 +72,7 @@ instance Pretty Def where instance Pretty Expr where pretty (App e as) = Bracket "(" ")" "" (map pretty (e:as)) pretty (Ref n) = Leaf n + pretty (Con n) = Leaf n pretty (Num n) = Leaf (show n) pretty (Tup es) = Bracket "(" ")" "," (map pretty es) pretty (Lam as e) = Bracket "(" ")" "" [Node ("\\" ++ intercalate " " as ++ " ->") [pretty e]] @@ -124,6 +126,7 @@ instance AllRefs Def where instance AllRefs Expr where allRefs (App e es) = nub $ concatMap allRefs (e : es) allRefs (Ref n) = [n] + allVars (Con _) = [] allRefs (Num _) = [] allRefs (Tup es) = nub $ concatMap allRefs es allRefs (Lam ns e) = allRefs e \\ ns -- cgit v1.2.3-70-g09d2