1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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)
|