created dummy monomorphizer
This commit is contained in:
parent
c19f821892
commit
c6e8305215
3 changed files with 57 additions and 15 deletions
|
|
@ -1,5 +1,8 @@
|
|||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Monomorphizer.Monomorphizer (monomorphize) where
|
||||
|
||||
import Grammar.Abs (Ident (..))
|
||||
import Monomorphizer.MonomorphizerIr
|
||||
import TypeChecker.TypeCheckerIr qualified as T
|
||||
|
||||
|
|
@ -14,4 +17,37 @@ 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
|
||||
monoBind (T.Bind name args (e, t)) = Bind name args (e, t)
|
||||
|
||||
monoExpr :: T.Exp -> Exp
|
||||
monoExpr = \case
|
||||
T.EId (Ident i) -> EId (Ident i)
|
||||
T.ELit lit -> ELit $ monoLit lit
|
||||
T.ELet bind expt -> ELet (monoBind bind) (monoexpt expt)
|
||||
T.EApp expt1 expt2 -> EApp (monoexpt expt1) (monoexpt expt2)
|
||||
T.EAdd expt1 expt2 -> EAdd (monoexpt expt1) (monoexpt expt2)
|
||||
T.EAbs i expt -> error "BUG"
|
||||
T.ECase expt injs -> ECase (monoexpt expt) (monoInjs injs)
|
||||
|
||||
monoType :: T.Type -> Type
|
||||
monoType (T.TAll _ t) = monoType t
|
||||
monoType (T.TVar (T.MkTVar i)) = error "NOT POLYMORPHIC TYPES"
|
||||
monoType (T.TLit i) = TLit i
|
||||
monoType (T.TFun t1 t2) = TFun (monoType t1) (monoType t2)
|
||||
|
||||
monoexpt :: T.ExpT -> ExpT
|
||||
monoexpt (e, t) = (e, t)
|
||||
|
||||
monoId :: T.Id -> Id
|
||||
monoId = id
|
||||
|
||||
monoLit :: T.Lit -> Lit
|
||||
monoLit (T.LInt i) = LInt i
|
||||
monoLit (T.LChar c) = LChar c
|
||||
|
||||
monoInjs = map monoInj
|
||||
|
||||
monoInj (T.Inj (init, t) expt) = Injection (monoInit init, monoType t) (monoexpt expt)
|
||||
|
||||
monoInit :: T.Init -> Init
|
||||
monoInit = id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue