diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-08 11:43:37 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-08 11:43:37 +0200 |
| commit | d91979adb9dc6eaa96f37ac0af337fed1aed08af (patch) | |
| tree | 591b4ea12fab099690402f143ee5cbc9b1b1edc3 | |
| parent | ea160e993a7196d0f5aa6749b1ea046f16cf0546 (diff) | |
Use Integer instead of Int in ASTInteger
| -rw-r--r-- | examples/fibo.milch | 2 | ||||
| -rw-r--r-- | src/Builtins.hs | 8 | ||||
| -rw-r--r-- | src/Utils.hs | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/examples/fibo.milch b/examples/fibo.milch index f6a14a8..160ecdf 100644 --- a/examples/fibo.milch +++ b/examples/fibo.milch @@ -4,4 +4,4 @@ 1 1 _ (+ (fibo (- n 1)) (fibo (- n 2)))))) -(fibo 50) +(fibo 300) diff --git a/src/Builtins.hs b/src/Builtins.hs index 079195f..e87cb09 100644 --- a/src/Builtins.hs +++ b/src/Builtins.hs @@ -207,10 +207,12 @@ builtinTail = (name, makeNonsenseAST $ ASTFunction Pure fn1) where builtinSubstr :: (String, AST) builtinSubstr = (name, makeNonsenseAST $ ASTFunction Pure fn1) where name = "substr" - fn1 ast1@AST { an = ASTInteger at } = + fn1 ast1@AST { an = ASTInteger atInteger } = return $ makeNonsenseAST $ ASTFunction Pure $ fn2 where - fn2 ast2@AST { an = ASTInteger len } = + fn2 ast2@AST { an = ASTInteger lenInteger } = return $ makeNonsenseAST $ ASTFunction Pure $ fn3 where + len = fromIntegral lenInteger :: Int + at = fromIntegral atInteger :: Int fn3 AST { an = ASTString str } = return $ makeNonsenseAST $ ASTString $ drop at .> take len $ str fn3 ast3 = throwL (astPos ast3) $ argError3 name ast1 ast2 ast3 @@ -258,7 +260,7 @@ builtinLen :: (String, AST) builtinLen = (name, makeNonsenseAST $ ASTFunction Pure fn1) where name = "len" fn1 AST { an = ASTString str } = - return $ makeNonsenseAST $ ASTInteger $ length str + return $ makeNonsenseAST $ ASTInteger $ fromIntegral $ length str fn1 ast1 = throwL (astPos ast1) $ argError1 name ast1 builtinFatal :: (String, AST) diff --git a/src/Utils.hs b/src/Utils.hs index e4b2333..0f0654c 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -124,7 +124,7 @@ type LFunction = AST -> LContext AST type LRecord = M.Map String AST data ASTNode - = ASTInteger Int + = ASTInteger Integer | ASTDouble Double | ASTSymbol String | ASTBoolean Bool |
