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 /src/Builtins.hs | |
| parent | ea160e993a7196d0f5aa6749b1ea046f16cf0546 (diff) | |
Use Integer instead of Int in ASTInteger
Diffstat (limited to 'src/Builtins.hs')
| -rw-r--r-- | src/Builtins.hs | 8 |
1 files changed, 5 insertions, 3 deletions
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) |
