diff options
| author | Jan Tuomi <jan.tuomi@valuemotive.com> | 2022-09-24 15:04:03 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-05 14:21:53 +0200 |
| commit | aec05f8d92a608f0fb34fd2453a647b43dcb777d (patch) | |
| tree | 68c04086d48e458de3a9bd9f512da7a7604a027a /src/Types.hs | |
| parent | 23d7d88e21eca2acf8649df9dc7b0a4c3277a8a4 (diff) | |
Separate Builtins module
Diffstat (limited to 'src/Types.hs')
| -rw-r--r-- | src/Types.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Types.hs b/src/Types.hs index d7fb35c..9953882 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -62,3 +62,30 @@ instance (Ord AST) where ASTVector a <= ASTVector b = a <= b ASTHashMap a <= ASTHashMap b = a <= b _ <= _ = False + +assertIsASTFunction :: AST -> LContext AST +assertIsASTFunction ast = case ast of + (ASTFunction _) -> return ast + _ -> throwError $ LException $ show ast ++ " is not a function" + +assertIsASTInteger :: AST -> LContext AST +assertIsASTInteger ast = case ast of + (ASTInteger _) -> return ast + _ -> throwError $ LException $ show ast ++ " is not an integer" + +assertIsASTSymbol :: AST -> LContext AST +assertIsASTSymbol ast = case ast of + (ASTSymbol _) -> return ast + _ -> throwError $ LException $ show ast ++ " is not a symbol" + +assertIsASTVector :: AST -> LContext AST +assertIsASTVector ast = case ast of + (ASTVector _) -> return ast + _ -> throwError $ LException $ show ast ++ " is not a vector" + +assertIsASTFunctionCall :: AST -> LContext AST +assertIsASTFunctionCall ast = case ast of + (ASTFunctionCall _) -> return ast + _ -> throwError $ LException $ show ast ++ " is not a function call or body" + +type Env = M.Map String AST |
