mono fixier
This commit is contained in:
parent
55fd35d661
commit
1a21698772
3 changed files with 18 additions and 22 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
module Monomorphizer.DataTypeRemover (removeDataTypes) where
|
module Monomorphizer.DataTypeRemover (removeDataTypes) where
|
||||||
import qualified Monomorphizer.MorbIr as M1
|
|
||||||
import qualified Monomorphizer.MonomorphizerIr as M2
|
import Monomorphizer.MonomorphizerIr qualified as M2
|
||||||
|
import Monomorphizer.MorbIr qualified as M1
|
||||||
import TypeChecker.TypeCheckerIr (Ident (Ident))
|
import TypeChecker.TypeCheckerIr (Ident (Ident))
|
||||||
|
|
||||||
removeDataTypes :: M1.Program -> M2.Program
|
removeDataTypes :: M1.Program -> M2.Program
|
||||||
|
|
@ -19,6 +20,7 @@ pCons (M1.Inj ident t) = M2.Inj ident (pType t)
|
||||||
pType :: M1.Type -> M2.Type
|
pType :: M1.Type -> M2.Type
|
||||||
pType (M1.TLit ident) = M2.TLit ident
|
pType (M1.TLit ident) = M2.TLit ident
|
||||||
pType (M1.TFun t1 t2) = M2.TFun (pType t1) (pType t2)
|
pType (M1.TFun t1 t2) = M2.TFun (pType t1) (pType t2)
|
||||||
|
pType (M1.TData (Ident "Bool") _) = M2.TLit (Ident "Bool")
|
||||||
pType d = M2.TLit (Ident (newName d)) -- This is the step
|
pType d = M2.TLit (Ident (newName d)) -- This is the step
|
||||||
|
|
||||||
newName :: M1.Type -> String
|
newName :: M1.Type -> String
|
||||||
|
|
@ -56,4 +58,3 @@ pPattern (M1.PEnum ident) = M2.PEnum ident
|
||||||
pLit :: M1.Lit -> M2.Lit
|
pLit :: M1.Lit -> M2.Lit
|
||||||
pLit (M1.LInt v) = M2.LInt v
|
pLit (M1.LInt v) = M2.LInt v
|
||||||
pLit (M1.LChar c) = M2.LChar c
|
pLit (M1.LChar c) = M2.LChar c
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -383,11 +383,7 @@ createNewData ((consIdent, consType, polyData) : input) o =
|
||||||
(M.Data newDataType [newCons])
|
(M.Data newDataType [newCons])
|
||||||
o
|
o
|
||||||
where
|
where
|
||||||
polyDataIdent = case polyData of
|
T.Data (T.TData polyDataIdent _) _ = polyData
|
||||||
T.Data (T.TData i _) _ -> i
|
|
||||||
T.Data (T.TLit i) _ -> i
|
|
||||||
t -> error $ "Data type is :" ++ show t ++ " which should be impossible"
|
|
||||||
|
|
||||||
newDataType = getDataType consType
|
newDataType = getDataType consType
|
||||||
newDataName = newName newDataType polyDataIdent
|
newDataName = newName newDataType polyDataIdent
|
||||||
newCons = M.Inj consIdent consType
|
newCons = M.Inj consIdent consType
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ instance ReportTEVar G.Type Type where
|
||||||
reportTEVar = \case
|
reportTEVar = \case
|
||||||
G.TLit lit -> pure $ TLit (coerce lit)
|
G.TLit lit -> pure $ TLit (coerce lit)
|
||||||
G.TVar (G.MkTVar i) -> pure $ TVar (MkTVar $ coerce i)
|
G.TVar (G.MkTVar i) -> pure $ TVar (MkTVar $ coerce i)
|
||||||
G.TData (G.UIdent "Bool") _ -> pure $ TLit (coerce "Bool")
|
|
||||||
G.TData name typs -> TData (coerce name) <$> reportTEVar typs
|
G.TData name typs -> TData (coerce name) <$> reportTEVar typs
|
||||||
G.TFun t1 t2 -> liftA2 TFun (reportTEVar t1) (reportTEVar t2)
|
G.TFun t1 t2 -> liftA2 TFun (reportTEVar t1) (reportTEVar t2)
|
||||||
G.TAll (G.MkTVar i) t -> TAll (MkTVar $ coerce i) <$> reportTEVar t
|
G.TAll (G.MkTVar i) t -> TAll (MkTVar $ coerce i) <$> reportTEVar t
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue