diff options
Diffstat (limited to 'app/Builtins.hs')
| -rw-r--r-- | app/Builtins.hs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/app/Builtins.hs b/app/Builtins.hs index 06c35a3..9e4215c 100644 --- a/app/Builtins.hs +++ b/app/Builtins.hs @@ -1,15 +1,19 @@ module Builtins where import Code +import Control.Monad.IO.Class import Control.Monad.Trans.State.Lazy import qualified Data.Map as M -import Env +import Env hiding (PrlgEnv) +import Interpreter (backtrack) import qualified Operators as O -import Debug.Trace +bi = Builtin -hello :: BuiltinFunc -hello = BuiltinFunc $ trace "hllo prlg" +hello = + bi $ do + liftIO $ putStrLn "hllo prlg" + return Nothing addBuiltins :: PrlgEnv () addBuiltins = do @@ -21,6 +25,9 @@ addBuiltins = do any1 <- findStruct "any" 1 eq2 <- findStruct "=" 2 hello0 <- findStruct "hello" 0 + fail0 <- findStruct "fail" 0 + true0 <- findStruct "true" 0 + prlgstate0 <- findStruct "prlgstate" 0 modify $ \s -> s { defs = @@ -32,7 +39,11 @@ addBuiltins = do , [Goal, U (Struct a1), U (Atom b), LastCall] ]) , (any1, [[U (VoidRef Nothing), NoGoal]]) - , (hello0, [[Builtin hello]]) + , (hello0, [[Invoke hello]]) + , (fail0, [[Invoke $ bi backtrack]]) + , (true0, [[Invoke $ bi (pure Nothing)]]) + , ( prlgstate0 + , [[Invoke $ bi (get >>= liftIO . print >> pure Nothing)]]) ] , ops = [(O.xfy "," 1000), (O.xfx "=" 700)] } |
