From d91979adb9dc6eaa96f37ac0af337fed1aed08af Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 8 Dec 2022 11:43:37 +0200 Subject: Use Integer instead of Int in ASTInteger --- src/Builtins.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Builtins.hs') 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) -- cgit v1.3