created dummy monomorphizer

This commit is contained in:
sebastianselander 2023-03-23 17:20:19 +01:00
parent 42c8ebc7b6
commit e3df4192bb
6 changed files with 279 additions and 393 deletions

View file

@ -1 +1,17 @@
module Monomorphizer.Monomorphizer where
module Monomorphizer.Monomorphizer (monomorphize) where
import Monomorphizer.MonomorphizerIr
import TypeChecker.TypeCheckerIr qualified as T
monomorphize :: T.Program -> Program
monomorphize (T.Program ds) = Program $ monoDefs ds
monoDefs :: [T.Def] -> [Def]
monoDefs = map monoDef
monoDef :: T.Def -> Def
monoDef (T.DBind bind) = DBind $ monoBind bind
monoDef (T.DData d) = DData d
monoBind :: T.Bind -> Bind
monoBind (T.Bind name args e) = Bind name args e

View file

@ -1,14 +1,19 @@
module Monomorphizer.MonomorphizerIr where
import Grammar.Abs (Ident)
newtype Program = Program [Bind]
import Grammar.Abs (Data, Ident, Init)
import TypeChecker.TypeCheckerIr (ExpT, Id, Indexed)
newtype Program = Program [Def]
deriving (Show, Ord, Eq)
data Bind = Bind Id [Id] ExpT | DataType Ident [Constructor]
data Def = DBind Bind | DData Data
deriving (Show, Ord, Eq)
data Bind = Bind Id [Id] ExpT
deriving (Show, Ord, Eq)
data Exp
= EId Id
= EId Id
| ELit Lit
| ELet Id ExpT ExpT
| EApp Type ExpT ExpT
@ -16,20 +21,15 @@ data Exp
| ECase Type ExpT [Injection]
deriving (Show, Ord, Eq)
data Injection = Injection Case ExpT
deriving (Show, Ord, Eq)
data Case = CLit Lit | CCons Id [Case] | CIdent Ident | CatchAll
deriving (Show, Ord, Eq)
data Injection = Injection (Init, Type) ExpT
deriving (Eq, Ord, Show)
data Constructor = Constructor Ident [Type]
deriving (Show, Ord, Eq)
type Id = (Ident, Type)
type ExpT = (Exp, Type)
data Lit = LInt Integer
| LChar Char
data Lit
= LInt Integer
| LChar Char
deriving (Show, Ord, Eq)
newtype Type = Type Ident