This commit is contained in:
msyds committed 2026-07-05 15:14:17 -06:00
1 parent 817b7530c1
commit a2c93938ca
5 files changed
+355 -6

No files matched your search

+15 -2
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE OverloadedLists #-}
module Gyehoek.CPS.Convert
( convert
) where
@@ -29,9 +30,21 @@ convert (Scm.ExpPrim p) k =
r <- gensym' "r"
ExpPrim p' [r] . pure <$> k (ValVar r)
convert (Scm.ExpLambda xs e) k = do
f <- gensym' "f"
ktail <- gensym' "ktail"
m <- convert e $ \e' ->
pure $ ExpApply (ValVar ktail) [e']
ExpFix [(f, MkKappa (xs ++ [ktail]) m)] <$> k (ValVar f)
convert (Scm.ExpApply f xs) k =
telescope (convert @es) (f:|xs) \(f':|xs') -> do
_
_
r <- gensym' "r"
x <- gensym' "x"
m <- k (ValVar x)
pure $ ExpFix [(r, MkKappa [x] m)] $ ExpApply f' (xs' ++ [ValVar r])
convert _ k = _
halt :: Applicative f => Val -> f Exp
halt = pure . ExpApply (ValVar "halt") . pure