From 83ae25fe87e3a56d169ae8cfc5bf20423d3ec4a5 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 27 Sep 2022 10:20:05 +0300 Subject: Add fatal builtin --- src/Builtins.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Builtins.hs b/src/Builtins.hs index 8dc96b2..d35ce17 100644 --- a/src/Builtins.hs +++ b/src/Builtins.hs @@ -18,7 +18,8 @@ builtinEnv = M.fromList [ builtinPrint, builtinConcat, builtinFmt, - ("unit", ASTUnit) + ("unit", ASTUnit), + builtinFatal ] argError1 :: Show a => String -> a -> String @@ -147,3 +148,11 @@ builtinFmt = (name, ASTFunction outer) where replaceAll n (x:xs) text = let text' = T.replace (T.pack $ "{" ++ show n ++ "}") (T.pack $ show x) text in replaceAll (n + 1) xs text' + +builtinFatal :: (String, AST) +builtinFatal = (name, ASTFunction outer) where + name = "fatal" + outer _ (ASTString str) = + throwL $ str + outer _ ast = + throwL $ argError1 name ast -- cgit v1.3