Add first draft of Idris post

This commit is contained in:
2020-02-29 15:36:57 -08:00
parent 9e399ebe3c
commit 33b1457e91
2 changed files with 114 additions and 4 deletions

View File

@@ -43,7 +43,7 @@ typecheck (BinOp o l r) = do
(ot ** f) <- typecheckOp o lt rt
pure (_ ** BinOperation f le re)
eval : {t : ExprType} -> SafeExpr t -> repr t
eval : SafeExpr t -> repr t
eval (IntLiteral i) = i
eval (BoolLiteral b) = b
eval (StringLiteral s) = s
@@ -58,7 +58,7 @@ tryEval : Expr -> String
tryEval ex =
case typecheck ex of
Left err => "Type error: " ++ err
Right (t ** e) => resultStr $ eval {t=t} e
Right (t ** e) => resultStr $ eval {t} e
main : IO ()
main = putStrLn $ tryEval $ BinOp Add (IntLit 6) (BinOp Multiply (IntLit 160) (IntLit 2))