From 8d5353dc8c7ef3eefb0ae4860e67602c455c1a58 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sun, 13 Nov 2022 00:46:38 +0100 Subject: builtins are built in --- app/Env.hs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'app/Env.hs') diff --git a/app/Env.hs b/app/Env.hs index ba86c9e..744762b 100644 --- a/app/Env.hs +++ b/app/Env.hs @@ -1,25 +1,22 @@ module Env where -import Code (Interp (..)) -import Control.Monad.IO.Class +import Code (Interp(..), PrlgEnv) import Control.Monad.Trans.State.Lazy import qualified IR -import qualified Operators -import System.Console.Haskeline -type PrlgEnv a = StateT Code.Interp (InputT IO) a - -withStrTable :: (IR.StrTable -> (IR.StrTable, a)) -> PrlgEnv a +withStrTable :: (IR.StrTable -> (IR.StrTable, a)) -> Env.PrlgEnv a withStrTable f = do st <- gets strtable let (st', x) = f st modify (\s -> s {strtable = st'}) return x -findStruct :: String -> Int -> PrlgEnv IR.Id +findStruct :: String -> Int -> Env.PrlgEnv IR.Id findStruct str arity = do stri <- findAtom str return IR.Id {IR.str = stri, IR.arity = arity} -findAtom :: String -> PrlgEnv Int +findAtom :: String -> Env.PrlgEnv Int findAtom = withStrTable . flip IR.strtablize + +type PrlgEnv a = Code.PrlgEnv a -- cgit v1.2.3