aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Config.hs
diff options
context:
space:
mode:
authorMarvin Borner2024-09-05 15:34:20 +0200
committerMarvin Borner2024-09-06 14:46:03 +0200
commitc95688c2fa63ba91df518ddf0d97261d6bd02426 (patch)
tree0c548056289d7551243dd73cb585f54d179403d1 /src/Config.hs
parentb565350fb5f44f57dcb02a66ae99bab3b27313d3 (diff)
Refactored Helper.hs
Diffstat (limited to 'src/Config.hs')
-rw-r--r--src/Config.hs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/Config.hs b/src/Config.hs
new file mode 100644
index 0000000..8b062ac
--- /dev/null
+++ b/src/Config.hs
@@ -0,0 +1,45 @@
+-- MIT License, Copyright (c) 2022 Marvin Borner
+module Config where
+
+import Data.Maybe ( fromMaybe
+ , isNothing
+ )
+
+data ArgMode = ArgEval | ArgEvalBblc | ArgEvalBlc | ArgDumpBblc | ArgDumpBlc
+
+data Args = Args
+ { _argMode :: ArgMode
+ , _argNoTests :: Bool
+ , _argVerbose :: Bool
+ , _argOptimize :: Bool
+ , _argToTarget :: String
+ , _argReducer :: String
+ , _argPath :: Maybe String
+ }
+
+data EvalConf = EvalConf
+ { _isRepl :: Bool
+ , _isVerbose :: Bool
+ , _evalTests :: Bool
+ , _optimize :: Bool
+ , _nicePath :: String
+ , _path :: String
+ , _evalPaths :: [String]
+ , _toTarget :: String
+ , _reducer :: String
+ , _hasArg :: Bool
+ }
+
+argsToConf :: Args -> EvalConf
+argsToConf args = EvalConf { _isRepl = isNothing $ _argPath args
+ , _isVerbose = _argVerbose args
+ , _evalTests = not $ _argNoTests args
+ , _optimize = _argOptimize args
+ , _path = path
+ , _nicePath = path
+ , _evalPaths = []
+ , _toTarget = _argToTarget args
+ , _reducer = _argReducer args
+ , _hasArg = False
+ }
+ where path = fromMaybe "" (_argPath args)