Made binds keep args instead of lambda converting
This commit is contained in:
parent
0012efabb7
commit
fc60112877
3 changed files with 18 additions and 13 deletions
|
|
@ -33,6 +33,8 @@ executable language
|
|||
Auxiliary
|
||||
TypeChecker.TypeChecker
|
||||
TypeChecker.TypeCheckerIr
|
||||
Monomorphizer.Monomorphizer
|
||||
Monomorphizer.MonomorphizerIr
|
||||
Renamer.Renamer
|
||||
Codegen.Codegen
|
||||
Codegen.LlvmIr
|
||||
|
|
|
|||
|
|
@ -106,18 +106,20 @@ checkPrg (Program bs) = do
|
|||
|
||||
checkBind :: Bind -> Infer T.Bind
|
||||
checkBind (Bind name args e) = do
|
||||
let lambda = makeLambda e (reverse $ coerce args)
|
||||
e@(_, t') <- inferExp lambda
|
||||
s <- gets sigs
|
||||
case M.lookup (coerce name) s of
|
||||
Just (Just t) -> do
|
||||
sub <- unify t t'
|
||||
let newT = apply sub t
|
||||
insertSig (coerce name) (Just newT)
|
||||
return $ T.Bind (coerce name, newT) [] e
|
||||
_ -> do
|
||||
insertSig (coerce name) (Just t')
|
||||
return (T.Bind (coerce name, t') [] e) -- (apply s e)
|
||||
-- let lambda = makeLambda e (reverse $ coerce args)
|
||||
args <- zip args <$> mapM (const fresh) args
|
||||
withBindings (map coerce args) $ do
|
||||
e@(_, t') <- inferExp e
|
||||
s <- gets sigs
|
||||
case M.lookup (coerce name) s of
|
||||
Just (Just t) -> do
|
||||
sub <- unify t t'
|
||||
let newT = apply sub t
|
||||
insertSig (coerce name) (Just newT)
|
||||
return $ T.Bind (coerce name, newT) (map coerce args) e
|
||||
_ -> do
|
||||
insertSig (coerce name) (Just t')
|
||||
return (T.Bind (coerce name, t') (map coerce args) e) -- (apply s e)
|
||||
where
|
||||
makeLambda :: Exp -> [Ident] -> Exp
|
||||
makeLambda = foldl (flip (EAbs . coerce))
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ instance Print Program where
|
|||
prt i (Program sc) = prPrec i 0 $ prt 0 sc
|
||||
|
||||
instance Print Bind where
|
||||
prt i (Bind (name, t) _ rhs) =
|
||||
prt i (Bind (name, t) args rhs) =
|
||||
prPrec i 0 $
|
||||
concatD
|
||||
[ prt 0 name
|
||||
|
|
@ -101,6 +101,7 @@ instance Print Bind where
|
|||
, prt 0 t
|
||||
, doc $ showString "\n"
|
||||
, prt 0 name
|
||||
, prtIdPs 0 args
|
||||
, doc $ showString "="
|
||||
, prt 0 rhs
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue