module Language.PureScript.Bridge.CodeGenSwitches
( Settings (..)
, ForeignOptions(..)
, defaultSettings
, Switch
, getSettings
, defaultSwitch
, noLenses, genLenses
, useGen, useGenRep
, genForeign, noForeign, noArgonautCodecs
, genArgonautCodecs
) where
import Data.Monoid (Endo(..))
data Settings = Settings
{ Settings -> Bool
generateLenses :: Bool
, Settings -> Bool
genericsGenRep :: Bool
, Settings -> Bool
generateArgonautCodecs :: Bool
, Settings -> Maybe ForeignOptions
generateForeign :: Maybe ForeignOptions
}
deriving (Settings -> Settings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Settings -> Settings -> Bool
$c/= :: Settings -> Settings -> Bool
== :: Settings -> Settings -> Bool
$c== :: Settings -> Settings -> Bool
Eq, Int -> Settings -> ShowS
[Settings] -> ShowS
Settings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Settings] -> ShowS
$cshowList :: [Settings] -> ShowS
show :: Settings -> String
$cshow :: Settings -> String
showsPrec :: Int -> Settings -> ShowS
$cshowsPrec :: Int -> Settings -> ShowS
Show)
data ForeignOptions = ForeignOptions
{ ForeignOptions -> Bool
unwrapSingleConstructors :: Bool
, ForeignOptions -> Bool
unwrapSingleArguments :: Bool
}
deriving (ForeignOptions -> ForeignOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ForeignOptions -> ForeignOptions -> Bool
$c/= :: ForeignOptions -> ForeignOptions -> Bool
== :: ForeignOptions -> ForeignOptions -> Bool
$c== :: ForeignOptions -> ForeignOptions -> Bool
Eq, Int -> ForeignOptions -> ShowS
[ForeignOptions] -> ShowS
ForeignOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ForeignOptions] -> ShowS
$cshowList :: [ForeignOptions] -> ShowS
show :: ForeignOptions -> String
$cshow :: ForeignOptions -> String
showsPrec :: Int -> ForeignOptions -> ShowS
$cshowsPrec :: Int -> ForeignOptions -> ShowS
Show)
defaultSettings :: Settings
defaultSettings :: Settings
defaultSettings = Bool -> Bool -> Bool -> Maybe ForeignOptions -> Settings
Settings Bool
True Bool
True Bool
True forall a. Maybe a
Nothing
type Switch = Endo Settings
getSettings :: Switch -> Settings
getSettings :: Switch -> Settings
getSettings Switch
switch = forall a. Endo a -> a -> a
appEndo Switch
switch Settings
defaultSettings
defaultSwitch :: Switch
defaultSwitch :: Switch
defaultSwitch = forall a. Monoid a => a
mempty
noLenses :: Switch
noLenses :: Switch
noLenses = forall a. (a -> a) -> Endo a
Endo forall a b. (a -> b) -> a -> b
$ \Settings
settings -> Settings
settings { generateLenses :: Bool
generateLenses = Bool
False }
noArgonautCodecs :: Switch
noArgonautCodecs :: Switch
noArgonautCodecs = forall a. (a -> a) -> Endo a
Endo forall a b. (a -> b) -> a -> b
$ \Settings
settings ->
Settings
settings { generateArgonautCodecs :: Bool
generateArgonautCodecs = Bool
False }
genLenses :: Switch
genLenses :: Switch
genLenses = forall a. (a -> a) -> Endo a
Endo forall a b. (a -> b) -> a -> b
$ \Settings
settings -> Settings
settings { generateLenses :: Bool
generateLenses = Bool
True }
useGenRep :: Switch
useGenRep :: Switch
useGenRep = forall a. (a -> a) -> Endo a
Endo forall a b. (a -> b) -> a -> b
$ \Settings
settings -> Settings
settings { genericsGenRep :: Bool
genericsGenRep = Bool
True }
useGen :: Switch
useGen :: Switch
useGen = forall a. (a -> a) -> Endo a
Endo forall a b. (a -> b) -> a -> b
$ \Settings
settings -> Settings
settings { genericsGenRep :: Bool
genericsGenRep = Bool
False }
genForeign :: ForeignOptions -> Switch
genForeign :: ForeignOptions -> Switch
genForeign ForeignOptions
opts = forall a. (a -> a) -> Endo a
Endo forall a b. (a -> b) -> a -> b
$ \Settings
settings -> Settings
settings { generateForeign :: Maybe ForeignOptions
generateForeign = forall a. a -> Maybe a
Just ForeignOptions
opts }
genArgonautCodecs :: Switch
genArgonautCodecs :: Switch
genArgonautCodecs = forall a. (a -> a) -> Endo a
Endo forall a b. (a -> b) -> a -> b
$ \Settings
settings ->
Settings
settings { generateArgonautCodecs :: Bool
generateArgonautCodecs = Bool
True }
noForeign :: Switch
noForeign :: Switch
noForeign = forall a. (a -> a) -> Endo a
Endo forall a b. (a -> b) -> a -> b
$ \Settings
settings -> Settings
settings { generateForeign :: Maybe ForeignOptions
generateForeign = forall a. Maybe a
Nothing }