From 5b610a39ff5e99ffaeecdeb41fbc46e8f0b201fe Mon Sep 17 00:00:00 2001 From: "Carsten Csiky (csicar)" Date: Sat, 21 Sep 2019 15:23:44 +0200 Subject: [PATCH] use kotlin's `tailrec` for TCO --- README.md | 2 +- src/CodeGen/Printer.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f32a5c1..c41e9d30 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ ToDos - [x] Build cache - [x] use Shake - [x] `--run` for spago CLI spec -- [ ] TCO +- [x] TCO: through Kotlin's `tailrec` - [ ] expand inlining - [x] `$` - [ ] `>`, `>=` ... diff --git a/src/CodeGen/Printer.hs b/src/CodeGen/Printer.hs index e4218dd8..2bc298f6 100644 --- a/src/CodeGen/Printer.hs +++ b/src/CodeGen/Printer.hs @@ -113,7 +113,7 @@ printExprAlg (LambdaF arg (_, body)) = braces $ (<> line') $ nest' $ printExprAlg (DeferF (Stmt _, body)) = "/* defer **/" <> body printExprAlg (DeferF (_, body)) = ("/* defer */" <>) $ braces $ nest' body printExprAlg (FunF mName args (_, body)) = - "fun" <+> maybe "" printKtIdent mName <> parens (commaSep $ (<+> ": Any") . printKtIdent <$> args) <> ": Any =" <+> body + "tailrec fun" <+> maybe "" printKtIdent mName <> parens (commaSep $ (<+> ": Any") . printKtIdent <$> args) <> ": Any =" <+> body printExprAlg (PropertyF (_, a) (_, b)) = align $ nest' $ a <> line' <> "." <> b printExprAlg (FunRefF qualIdent) = parens $ "::" <> printQualified printKtIdent qualIdent printExprAlg (ConstF lit) = printLiteral lit