diff options
author | Marvin Borner | 2022-08-22 15:29:42 +0200 |
---|---|---|
committer | Marvin Borner | 2022-08-22 15:29:42 +0200 |
commit | 4ed788a832655006171754d15d370a6b64793477 (patch) | |
tree | 29ec80742ef600436c7267fbb840cddc30b394f8 /src/Helper.hs | |
parent | a26c8e542dba44e348ac723ed3f6252c6a7496b4 (diff) |
Fixed leaking imports
Diffstat (limited to 'src/Helper.hs')
-rw-r--r-- | src/Helper.hs | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/Helper.hs b/src/Helper.hs index 2ec40a3..78b1f1c 100644 --- a/src/Helper.hs +++ b/src/Helper.hs @@ -14,8 +14,8 @@ import qualified Data.Map as M import Text.Megaparsec data Context = Context - { ctxInput :: String - , ctxPath :: String + { _ctxInput :: String + , _ctxPath :: String } printContext :: Context -> String @@ -121,18 +121,38 @@ instance Show Expression where show (Prefix p e) = show p <> " " <> show e data EvalConf = EvalConf - { isRepl :: Bool - , evalTests :: Bool - , nicePath :: String - , evalPaths :: [String] + { _isRepl :: Bool + , _evalTests :: Bool + , _nicePath :: String + , _evalPaths :: [String] + } +data ExpFlags = ExpFlags + { _isImported :: Bool + } + deriving Show +data EnvDef = EnvDef + { _exp :: Expression + , _sub :: Environment + , _flags :: ExpFlags } -data Environment = Environment (M.Map Identifier (Expression, Environment)) + deriving Show +data Environment = Environment (M.Map Identifier EnvDef) deriving Show data EnvCache = EnvCache { _imported :: M.Map String Environment } type EvalState = S.State Environment +defaultConf :: String -> EvalConf +defaultConf path = EvalConf { _isRepl = False + , _evalTests = True + , _nicePath = path + , _evalPaths = [] + } + +defaultFlags :: ExpFlags +defaultFlags = ExpFlags { _isImported = False } + --- listify :: [Expression] -> Expression @@ -193,7 +213,7 @@ decodeStdout e = do matchingFunctions :: Expression -> Environment -> String matchingFunctions e (Environment env) = intercalate ", " $ map (functionName . fst) $ M.toList $ M.filter - (\(e', _) -> e == e') + (\EnvDef { _exp = e' } -> e == e') env -- TODO: Expression -> Maybe Char is missing |