module Data.Record.Anon.Internal.Plugin.Source.Options (
Options(..)
, parseOpts
, Mode(..)
, parseMode
) where
data Options = Options {
Options -> Bool
debug :: Bool
, Options -> Bool
typelet :: Bool
, Options -> Bool
noapply :: Bool
}
defaultOptions :: Options
defaultOptions :: Options
defaultOptions = Options {
debug :: Bool
debug = Bool
False
, typelet :: Bool
typelet = Bool
False
, noapply :: Bool
noapply = Bool
False
}
parseOpts :: [String] -> Options
parseOpts :: [String] -> Options
parseOpts = (forall a b. (a -> b) -> a -> b
$ Options
defaultOptions) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) forall a. a -> a
id forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map String -> Options -> Options
aux
where
aux :: String -> Options -> Options
aux :: String -> Options -> Options
aux String
"debug" Options
opts = Options
opts { debug :: Bool
debug = Bool
True }
aux String
"typelet" Options
opts = Options
opts { typelet :: Bool
typelet = Bool
True }
aux String
"noapply" Options
opts = Options
opts { noapply :: Bool
noapply = Bool
True }
aux String
opt Options
_ = forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String
"invalid option: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show String
opt
data Mode = Simple | Advanced
parseMode :: String -> Maybe Mode
parseMode :: String -> Maybe Mode
parseMode String
"ANON" = forall a. a -> Maybe a
Just Mode
Simple
parseMode String
"ANON_F" = forall a. a -> Maybe a
Just Mode
Advanced
parseMode String
_ = forall a. Maybe a
Nothing