From 2886ae5ba8addbb86a3fad52ccc65b3309e12fcd Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Tue, 13 Feb 2024 20:55:24 +0100 Subject: Cleanup --- AST.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'AST.hs') diff --git a/AST.hs b/AST.hs index cae9ecb..2e1bb13 100644 --- a/AST.hs +++ b/AST.hs @@ -1,14 +1,19 @@ module AST where +import Data.List.NonEmpty (NonEmpty) + + +newtype Name = Name String + deriving (Show, Eq) data Program t = Program [FunDef t] deriving (Show) -data FunDef t = FunDef Name (Maybe Type) [FunEq t] +data FunDef t = FunDef Name (Maybe Type) (NonEmpty (FunEq t)) deriving (Show) -newtype Name = Name String - deriving (Show, Eq) +data FunEq t = FunEq Name [Pattern t] (RHS t) + deriving (Show) data Type = TApp Type [Type] @@ -19,9 +24,6 @@ data Type | TVar Name deriving (Show) -data FunEq t = FunEq Name [Pattern t] (RHS t) - deriving (Show) - data Pattern t = PWildcard t | PVar t Name @@ -32,7 +34,7 @@ data Pattern t deriving (Show) data RHS t - = Guarded [(Expr t, Expr t)] + = Guarded [(Expr t, Expr t)] -- currently not parsed | Plain (Expr t) deriving (Show) -- cgit v1.2.3-70-g09d2