diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-09-25 17:52:12 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-05 14:21:53 +0200 |
| commit | 6314bf6584f98c735f606155a76c809fd6de5d0b (patch) | |
| tree | 085d07e116933f23f7db7beaadd03ada1c9dc918 /src/Builtins.hs | |
| parent | 218ad3f54ef0be7e0b2e288e543e6c0959ddd7e3 (diff) | |
Add throwL
Diffstat (limited to 'src/Builtins.hs')
| -rw-r--r-- | src/Builtins.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Builtins.hs b/src/Builtins.hs index 1ac532a..37c9238 100644 --- a/src/Builtins.hs +++ b/src/Builtins.hs @@ -2,8 +2,8 @@ module Builtins where import qualified Data.Map as M -import Control.Monad.Except ( when, MonadError(throwError) ) -import Types +import Control.Monad.Except +import Utils builtinEnv :: Env builtinEnv = M.fromList [ @@ -25,15 +25,15 @@ builtinAdd2 = let inner :: LFunction inner _ (ASTInteger b) = return $ ASTInteger $ a + b - inner _ other = throwError $ LException $ "invalid argument to integer add: " ++ show other + inner _ other = throwL $ "invalid argument to integer add: " ++ show other return $ ASTFunction $ inner outer _ (ASTDouble a) = do let inner :: LFunction inner _ (ASTDouble b) = return $ ASTDouble $ a + b - inner _ other = throwError $ LException $ "invalid argument to double add: " ++ show other + inner _ other = throwL $ "invalid argument to double add: " ++ show other return $ ASTFunction $ inner - outer _ other = throwError $ LException $ "non-numeric argument to add: " ++ show other + outer _ other = throwL $ "non-numeric argument to add: " ++ show other in ASTFunction outer @@ -63,7 +63,7 @@ builtinDivide2 = (ASTInteger a) <- assertIsASTInteger ast1 let inner _ ast2 = do (ASTInteger b) <- assertIsASTInteger ast2 - when (b == 0) $ throwError $ LException $ "division by zero" + when (b == 0) $ throwL $ "division by zero" return $ ASTInteger $ a `div` b return $ ASTFunction $ inner in ASTFunction outer @@ -72,7 +72,7 @@ builtinHead :: AST builtinHead = let outer _ ast = do (ASTVector vec) <- assertIsASTVector ast - when (length vec == 0) $ throwError $ LException $ "head of empty vector" + when (length vec == 0) $ throwL $ "head of empty vector" return $ head vec in ASTFunction outer @@ -80,7 +80,7 @@ builtinTail :: AST builtinTail = let outer _ ast = do (ASTVector vec) <- assertIsASTVector ast - when (length vec == 0) $ throwError $ LException $ "tail of empty vector" + when (length vec == 0) $ throwL $ "tail of empty vector" return $ ASTVector $ tail vec in ASTFunction outer @@ -91,4 +91,4 @@ builtinPrepend = (ASTVector vec) <- assertIsASTVector ast2 return $ ASTVector $ ast1 : vec return $ ASTFunction $ inner - in ASTFunction outer
\ No newline at end of file + in ASTFunction outer |
