{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
module Test.WebDriver.Capabilities where
import Test.WebDriver.Chrome.Extension
import Test.WebDriver.Firefox.Profile
import Test.WebDriver.JSON
import Data.Aeson
import Data.Aeson.Types (Parser, typeMismatch, Pair)
import Data.Text (Text, toLower, toUpper)
import Data.Default (Default, def)
import Data.Word (Word16)
import Data.Maybe (fromMaybe, catMaybes)
import Data.String (fromString)
import Control.Applicative
import Control.Exception.Lifted (throw)
import Prelude
#if MIN_VERSION_aeson(2,0,0)
import qualified Data.Aeson.KeyMap as HM (delete, toList, empty)
#else
import qualified Data.HashMap.Strict as HM (delete, toList, empty)
#endif
class GetCapabilities t where
getCaps :: t -> Capabilities
instance GetCapabilities Capabilities where
getCaps :: Capabilities -> Capabilities
getCaps = Capabilities -> Capabilities
forall a. a -> a
id
class SetCapabilities t where
setCaps :: Capabilities -> t -> t
type HasCapabilities t = (GetCapabilities t, SetCapabilities t)
modifyCaps :: HasCapabilities t => (Capabilities -> Capabilities) -> t -> t
modifyCaps :: forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps Capabilities -> Capabilities
f t
c = Capabilities -> t -> t
forall t. SetCapabilities t => Capabilities -> t -> t
setCaps (Capabilities -> Capabilities
f (t -> Capabilities
forall t. GetCapabilities t => t -> Capabilities
getCaps t
c)) t
c
useBrowser :: HasCapabilities t => Browser -> t -> t
useBrowser :: forall t. HasCapabilities t => Browser -> t -> t
useBrowser Browser
b = (Capabilities -> Capabilities) -> t -> t
forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps ((Capabilities -> Capabilities) -> t -> t)
-> (Capabilities -> Capabilities) -> t -> t
forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { browser = b }
useVersion :: HasCapabilities t => String -> t -> t
useVersion :: forall t. HasCapabilities t => String -> t -> t
useVersion String
v = (Capabilities -> Capabilities) -> t -> t
forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps ((Capabilities -> Capabilities) -> t -> t)
-> (Capabilities -> Capabilities) -> t -> t
forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { version = Just v }
usePlatform :: HasCapabilities t => Platform -> t -> t
usePlatform :: forall t. HasCapabilities t => Platform -> t -> t
usePlatform Platform
p = (Capabilities -> Capabilities) -> t -> t
forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps ((Capabilities -> Capabilities) -> t -> t)
-> (Capabilities -> Capabilities) -> t -> t
forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { platform = p }
useProxy :: HasCapabilities t => ProxyType -> t -> t
useProxy :: forall t. HasCapabilities t => ProxyType -> t -> t
useProxy ProxyType
p = (Capabilities -> Capabilities) -> t -> t
forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps ((Capabilities -> Capabilities) -> t -> t)
-> (Capabilities -> Capabilities) -> t -> t
forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { proxy = p }
data Capabilities =
Capabilities {
Capabilities -> Browser
browser :: Browser
, Capabilities -> Maybe String
version :: Maybe String
, Capabilities -> Platform
platform :: Platform
, Capabilities -> ProxyType
proxy :: ProxyType
, Capabilities -> Maybe Bool
javascriptEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
takesScreenshot :: Maybe Bool
, Capabilities -> Maybe Bool
handlesAlerts :: Maybe Bool
, Capabilities -> Maybe Bool
databaseEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
locationContextEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
applicationCacheEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
browserConnectionEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
cssSelectorsEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
webStorageEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
rotatable :: Maybe Bool
, Capabilities -> Maybe Bool
acceptSSLCerts :: Maybe Bool
, Capabilities -> Maybe Bool
nativeEvents :: Maybe Bool
, Capabilities -> Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
, Capabilities -> [Pair]
additionalCaps :: [Pair]
} deriving (Capabilities -> Capabilities -> Bool
(Capabilities -> Capabilities -> Bool)
-> (Capabilities -> Capabilities -> Bool) -> Eq Capabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Capabilities -> Capabilities -> Bool
== :: Capabilities -> Capabilities -> Bool
$c/= :: Capabilities -> Capabilities -> Bool
/= :: Capabilities -> Capabilities -> Bool
Eq, Int -> Capabilities -> ShowS
[Capabilities] -> ShowS
Capabilities -> String
(Int -> Capabilities -> ShowS)
-> (Capabilities -> String)
-> ([Capabilities] -> ShowS)
-> Show Capabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Capabilities -> ShowS
showsPrec :: Int -> Capabilities -> ShowS
$cshow :: Capabilities -> String
show :: Capabilities -> String
$cshowList :: [Capabilities] -> ShowS
showList :: [Capabilities] -> ShowS
Show)
instance Default Capabilities where
def :: Capabilities
def = Capabilities { browser :: Browser
browser = Browser
firefox
, version :: Maybe String
version = Maybe String
forall a. Maybe a
Nothing
, platform :: Platform
platform = Platform
Any
, javascriptEnabled :: Maybe Bool
javascriptEnabled = Maybe Bool
forall a. Maybe a
Nothing
, takesScreenshot :: Maybe Bool
takesScreenshot = Maybe Bool
forall a. Maybe a
Nothing
, handlesAlerts :: Maybe Bool
handlesAlerts = Maybe Bool
forall a. Maybe a
Nothing
, databaseEnabled :: Maybe Bool
databaseEnabled = Maybe Bool
forall a. Maybe a
Nothing
, locationContextEnabled :: Maybe Bool
locationContextEnabled = Maybe Bool
forall a. Maybe a
Nothing
, applicationCacheEnabled :: Maybe Bool
applicationCacheEnabled = Maybe Bool
forall a. Maybe a
Nothing
, browserConnectionEnabled :: Maybe Bool
browserConnectionEnabled = Maybe Bool
forall a. Maybe a
Nothing
, cssSelectorsEnabled :: Maybe Bool
cssSelectorsEnabled = Maybe Bool
forall a. Maybe a
Nothing
, webStorageEnabled :: Maybe Bool
webStorageEnabled = Maybe Bool
forall a. Maybe a
Nothing
, rotatable :: Maybe Bool
rotatable = Maybe Bool
forall a. Maybe a
Nothing
, acceptSSLCerts :: Maybe Bool
acceptSSLCerts = Maybe Bool
forall a. Maybe a
Nothing
, nativeEvents :: Maybe Bool
nativeEvents = Maybe Bool
forall a. Maybe a
Nothing
, proxy :: ProxyType
proxy = ProxyType
UseSystemSettings
, unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior = Maybe UnexpectedAlertBehavior
forall a. Maybe a
Nothing
, additionalCaps :: [Pair]
additionalCaps = []
}
defaultCaps :: Capabilities
defaultCaps :: Capabilities
defaultCaps = Capabilities
forall a. Default a => a
def
allCaps :: Capabilities
allCaps :: Capabilities
allCaps = Capabilities
defaultCaps { javascriptEnabled = Just True
, takesScreenshot = Just True
, handlesAlerts = Just True
, databaseEnabled = Just True
, locationContextEnabled = Just True
, applicationCacheEnabled = Just True
, browserConnectionEnabled = Just True
, cssSelectorsEnabled = Just True
, webStorageEnabled = Just True
, rotatable = Just True
, acceptSSLCerts = Just True
, nativeEvents = Just True
}
instance ToJSON Capabilities where
toJSON :: Capabilities -> Value
toJSON Capabilities{[Pair]
Maybe Bool
Maybe String
Maybe UnexpectedAlertBehavior
ProxyType
Platform
Browser
browser :: Capabilities -> Browser
version :: Capabilities -> Maybe String
platform :: Capabilities -> Platform
proxy :: Capabilities -> ProxyType
javascriptEnabled :: Capabilities -> Maybe Bool
takesScreenshot :: Capabilities -> Maybe Bool
handlesAlerts :: Capabilities -> Maybe Bool
databaseEnabled :: Capabilities -> Maybe Bool
locationContextEnabled :: Capabilities -> Maybe Bool
applicationCacheEnabled :: Capabilities -> Maybe Bool
browserConnectionEnabled :: Capabilities -> Maybe Bool
cssSelectorsEnabled :: Capabilities -> Maybe Bool
webStorageEnabled :: Capabilities -> Maybe Bool
rotatable :: Capabilities -> Maybe Bool
acceptSSLCerts :: Capabilities -> Maybe Bool
nativeEvents :: Capabilities -> Maybe Bool
unexpectedAlertBehavior :: Capabilities -> Maybe UnexpectedAlertBehavior
additionalCaps :: Capabilities -> [Pair]
browser :: Browser
version :: Maybe String
platform :: Platform
proxy :: ProxyType
javascriptEnabled :: Maybe Bool
takesScreenshot :: Maybe Bool
handlesAlerts :: Maybe Bool
databaseEnabled :: Maybe Bool
locationContextEnabled :: Maybe Bool
applicationCacheEnabled :: Maybe Bool
browserConnectionEnabled :: Maybe Bool
cssSelectorsEnabled :: Maybe Bool
webStorageEnabled :: Maybe Bool
rotatable :: Maybe Bool
acceptSSLCerts :: Maybe Bool
nativeEvents :: Maybe Bool
unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
additionalCaps :: [Pair]
..} =
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ (Pair -> Bool) -> [Pair] -> [Pair]
forall a. (a -> Bool) -> [a] -> [a]
filter (\Pair
p -> Pair -> Value
forall a b. (a, b) -> b
snd Pair
p Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
/= Value
Null)
([Pair] -> [Pair]) -> [Pair] -> [Pair]
forall a b. (a -> b) -> a -> b
$ [ Key
"browserName" Key -> Browser -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Browser
browser
, Key
"version" Key -> Maybe String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe String
version
, Key
"platform" Key -> Platform -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Platform
platform
, Key
"proxy" Key -> ProxyType -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ProxyType
proxy
, Key
"javascriptEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
javascriptEnabled
, Key
"takesScreenshot" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
takesScreenshot
, Key
"handlesAlerts" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
handlesAlerts
, Key
"databaseEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
databaseEnabled
, Key
"locationContextEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
locationContextEnabled
, Key
"applicationCacheEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
applicationCacheEnabled
, Key
"browserConnectionEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
browserConnectionEnabled
, Key
"cssSelectorsEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
cssSelectorsEnabled
, Key
"webStorageEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
webStorageEnabled
, Key
"rotatable" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
rotatable
, Key
"acceptSslCerts" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
acceptSSLCerts
, Key
"nativeEvents" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
nativeEvents
, Key
"unexpectedAlertBehavior" Key -> Maybe UnexpectedAlertBehavior -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior
]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [Pair]
browserInfo
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [Pair]
additionalCaps
where
browserInfo :: [Pair]
browserInfo = case Browser
browser of
Firefox {Maybe Bool
Maybe String
Maybe (PreparedProfile Firefox)
LogLevel
ffProfile :: Maybe (PreparedProfile Firefox)
ffLogPref :: LogLevel
ffBinary :: Maybe String
ffAcceptInsecureCerts :: Maybe Bool
ffProfile :: Browser -> Maybe (PreparedProfile Firefox)
ffLogPref :: Browser -> LogLevel
ffBinary :: Browser -> Maybe String
ffAcceptInsecureCerts :: Browser -> Maybe Bool
..}
-> [Key
"firefox_profile" Key -> Maybe (PreparedProfile Firefox) -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe (PreparedProfile Firefox)
ffProfile
,Key
"loggingPrefs" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [Key
"driver" Key -> LogLevel -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= LogLevel
ffLogPref]
,Key
"firefox_binary" Key -> Maybe String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe String
ffBinary
,Key
"acceptInsecureCerts" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool -> Maybe Bool -> Bool
forall a. a -> Maybe a -> a
fromMaybe Bool
False Maybe Bool
ffAcceptInsecureCerts
]
Chrome {[String]
[ChromeExtension]
Maybe String
Object
chromeDriverVersion :: Maybe String
chromeBinary :: Maybe String
chromeOptions :: [String]
chromeExtensions :: [ChromeExtension]
chromeExperimentalOptions :: Object
chromeDriverVersion :: Browser -> Maybe String
chromeBinary :: Browser -> Maybe String
chromeOptions :: Browser -> [String]
chromeExtensions :: Browser -> [ChromeExtension]
chromeExperimentalOptions :: Browser -> Object
..}
-> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes [ Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"chrome.chromedriverVersion" Maybe String
chromeDriverVersion ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Key
"chromeOptions" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object ([Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
[ Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"binary" Maybe String
chromeBinary
] [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++
[ Key
"args" Key -> [String] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [String]
chromeOptions
, Key
"extensions" Key -> [ChromeExtension] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [ChromeExtension]
chromeExtensions
] [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ Object -> [Pair]
forall v. KeyMap v -> [(Key, v)]
HM.toList Object
chromeExperimentalOptions
)]
IE {Bool
Integer
Maybe String
Maybe Text
IEElementScrollBehavior
IELogLevel
ieIgnoreProtectedModeSettings :: Bool
ieIgnoreZoomSetting :: Bool
ieInitialBrowserUrl :: Maybe Text
ieElementScrollBehavior :: IEElementScrollBehavior
ieEnablePersistentHover :: Bool
ieEnableElementCacheCleanup :: Bool
ieRequireWindowFocus :: Bool
ieBrowserAttachTimeout :: Integer
ieLogFile :: Maybe String
ieLogLevel :: IELogLevel
ieHost :: Maybe Text
ieExtractPath :: Maybe Text
ieSilent :: Bool
ieForceCreateProcess :: Bool
ieSwitches :: Maybe Text
ieIgnoreProtectedModeSettings :: Browser -> Bool
ieIgnoreZoomSetting :: Browser -> Bool
ieInitialBrowserUrl :: Browser -> Maybe Text
ieElementScrollBehavior :: Browser -> IEElementScrollBehavior
ieEnablePersistentHover :: Browser -> Bool
ieEnableElementCacheCleanup :: Browser -> Bool
ieRequireWindowFocus :: Browser -> Bool
ieBrowserAttachTimeout :: Browser -> Integer
ieLogFile :: Browser -> Maybe String
ieLogLevel :: Browser -> IELogLevel
ieHost :: Browser -> Maybe Text
ieExtractPath :: Browser -> Maybe Text
ieSilent :: Browser -> Bool
ieForceCreateProcess :: Browser -> Bool
ieSwitches :: Browser -> Maybe Text
..}
-> [Key
"ignoreProtectedModeSettings" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieIgnoreProtectedModeSettings
,Key
"ignoreZoomSetting" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieIgnoreZoomSetting
,Key
"initialBrowserUrl" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieInitialBrowserUrl
,Key
"elementScrollBehavior" Key -> IEElementScrollBehavior -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= IEElementScrollBehavior
ieElementScrollBehavior
,Key
"enablePersistentHover" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieEnablePersistentHover
,Key
"enableElementCacheCleanup" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieEnableElementCacheCleanup
,Key
"requireWindowFocus" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieRequireWindowFocus
,Key
"browserAttachTimeout" Key -> Integer -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Integer
ieBrowserAttachTimeout
,Key
"logFile" Key -> Maybe String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe String
ieLogFile
,Key
"logLevel" Key -> IELogLevel -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= IELogLevel
ieLogLevel
,Key
"host" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieHost
,Key
"extractPath" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieExtractPath
,Key
"silent" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieSilent
,Key
"forceCreateProcess" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieForceCreateProcess
,Key
"internetExplorerSwitches" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieSwitches
]
Opera{Bool
Maybe Int
Maybe String
Maybe Word16
LogLevel
operaBinary :: Maybe String
operaProduct :: Maybe String
operaDetach :: Bool
operaAutoStart :: Bool
operaIdle :: Bool
operaDisplay :: Maybe Int
operaLauncher :: Maybe String
operaPort :: Maybe Word16
operaHost :: Maybe String
operaOptions :: Maybe String
operaLogFile :: Maybe String
operaLogPref :: LogLevel
operaBinary :: Browser -> Maybe String
operaProduct :: Browser -> Maybe String
operaDetach :: Browser -> Bool
operaAutoStart :: Browser -> Bool
operaIdle :: Browser -> Bool
operaDisplay :: Browser -> Maybe Int
operaLauncher :: Browser -> Maybe String
operaPort :: Browser -> Maybe Word16
operaHost :: Browser -> Maybe String
operaOptions :: Browser -> Maybe String
operaLogFile :: Browser -> Maybe String
operaLogPref :: Browser -> LogLevel
..}
-> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes [ Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.binary" Maybe String
operaBinary
, Key -> Maybe Int -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.display" Maybe Int
operaDisplay
, Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.product" Maybe String
operaProduct
, Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.launcher" Maybe String
operaLauncher
, Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.host" Maybe String
operaHost
, Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.logging.file" Maybe String
operaLogFile
]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [Key
"opera.detatch" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
operaDetach
,Key
"opera.no_quit" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
operaDetach
,Key
"opera.autostart" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
operaAutoStart
, Key
"opera.idle" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
operaIdle
,Key
"opera.port" Key -> Word16 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Word16 -> Maybe Word16 -> Word16
forall a. a -> Maybe a -> a
fromMaybe Word16
forall a. Bounded a => a
maxBound Maybe Word16
operaPort
,Key
"opera.arguments" Key -> Maybe String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe String
operaOptions
,Key
"opera.logging.level" Key -> LogLevel -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= LogLevel
operaLogPref
]
Phantomjs {[String]
Maybe String
phantomjsBinary :: Maybe String
phantomjsOptions :: [String]
phantomjsBinary :: Browser -> Maybe String
phantomjsOptions :: Browser -> [String]
..}
-> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes [ Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"phantomjs.binary.path" Maybe String
phantomjsBinary
] [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++
[ Key
"phantomjs.cli.args" Key -> [String] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [String]
phantomjsOptions
]
Browser
_ -> []
where
opt :: Key -> f a -> f b
opt Key
k = (a -> b) -> f a -> f b
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Key
k Key -> a -> b
forall v. ToJSON v => Key -> v -> b
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
instance FromJSON Capabilities where
parseJSON :: Value -> Parser Capabilities
parseJSON (Object Object
o) = do
Browser
browser <- Text -> Parser Browser
forall a. FromJSON a => Text -> Parser a
req Text
"browserName"
Browser
-> Maybe String
-> Platform
-> ProxyType
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities
Capabilities (Browser
-> Maybe String
-> Platform
-> ProxyType
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser Browser
-> Parser
(Maybe String
-> Platform
-> ProxyType
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Browser -> Parser Browser
getBrowserCaps Browser
browser
Parser
(Maybe String
-> Platform
-> ProxyType
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe String)
-> Parser
(Platform
-> ProxyType
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"version" Maybe String
forall a. Maybe a
Nothing
Parser
(Platform
-> ProxyType
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser Platform
-> Parser
(ProxyType
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser Platform
forall a. FromJSON a => Text -> Parser a
req Text
"platform"
Parser
(ProxyType
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser ProxyType
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> ProxyType -> Parser ProxyType
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"proxy" ProxyType
NoProxy
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"javascriptEnabled"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"takesScreenshot"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"handlesAlerts"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"databaseEnabled"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"locationContextEnabled"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"applicationCacheEnabled"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"browserConnectionEnabled"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"cssSelectorEnabled"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"webStorageEnabled"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"rotatable"
Parser
(Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities)
-> Parser (Maybe Bool)
-> Parser
(Maybe Bool
-> Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"acceptSslCerts"
Parser
(Maybe Bool
-> Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities)
-> Parser (Maybe Bool)
-> Parser (Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"nativeEvents"
Parser (Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities)
-> Parser (Maybe UnexpectedAlertBehavior)
-> Parser ([Pair] -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> Maybe UnexpectedAlertBehavior
-> Parser (Maybe UnexpectedAlertBehavior)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"unexpectedAlertBehaviour" Maybe UnexpectedAlertBehavior
forall a. Maybe a
Nothing
Parser ([Pair] -> Capabilities)
-> Parser [Pair] -> Parser Capabilities
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Pair] -> Parser [Pair]
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Browser -> [Pair]
additionalCapabilities Browser
browser)
where
req :: FromJSON a => Text -> Parser a
req :: forall a. FromJSON a => Text -> Parser a
req = (Object
o Object -> Key -> Parser a
forall a. FromJSON a => Object -> Key -> Parser a
.:) (Key -> Parser a) -> (Text -> Key) -> Text -> Parser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Key
fromText
opt :: FromJSON a => Text -> a -> Parser a
opt :: forall a. FromJSON a => Text -> a -> Parser a
opt Text
k a
d = Object
o Object -> Text -> Parser (Maybe a)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:?? Text
k Parser (Maybe a) -> a -> Parser a
forall a. Parser (Maybe a) -> a -> Parser a
.!= a
d
b :: Text -> Parser (Maybe Bool)
b :: Text -> Parser (Maybe Bool)
b Text
k = Text -> Maybe Bool -> Parser (Maybe Bool)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
k Maybe Bool
forall a. Maybe a
Nothing
additionalCapabilities :: Browser -> [Pair]
additionalCapabilities = Object -> [Pair]
forall v. KeyMap v -> [(Key, v)]
HM.toList (Object -> [Pair]) -> (Browser -> Object) -> Browser -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Key -> Object -> Object) -> Object -> [Key] -> Object
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Key -> Object -> Object
forall v. Key -> KeyMap v -> KeyMap v
HM.delete Object
o ([Key] -> Object) -> (Browser -> [Key]) -> Browser -> Object
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Browser -> [Key]
forall {a}. IsString a => Browser -> [a]
knownCapabilities
knownCapabilities :: Browser -> [a]
knownCapabilities Browser
browser =
[ a
"browserName", a
"version", a
"platform", a
"proxy"
, a
"javascriptEnabled", a
"takesScreenshot", a
"handlesAlerts"
, a
"databaseEnabled", a
"locationContextEnabled"
, a
"applicationCacheEnabled", a
"browserConnectionEnabled"
, a
"cssSelectorEnabled",a
"webStorageEnabled", a
"rotatable"
, a
"acceptSslCerts", a
"nativeEvents", a
"unexpectedBrowserBehaviour"]
[a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ case Browser
browser of
Firefox {} -> [a
"firefox_profile", a
"loggingPrefs", a
"firefox_binary", a
"acceptInsecureCerts"]
Chrome {} -> [a
"chrome.chromedriverVersion", a
"chrome.extensions", a
"chrome.switches", a
"chrome.extensions"]
IE {} -> [a
"ignoreProtectedModeSettings", a
"ignoreZoomSettings", a
"initialBrowserUrl", a
"elementScrollBehavior"
,a
"enablePersistentHover", a
"enableElementCacheCleanup", a
"requireWindowFocus", a
"browserAttachTimeout"
,a
"logFile", a
"logLevel", a
"host", a
"extractPath", a
"silent", a
"forceCreateProcess", a
"internetExplorerSwitches"]
Opera {} -> [a
"opera.binary", a
"opera.product", a
"opera.no_quit", a
"opera.autostart", a
"opera.idle", a
"opera.display"
,a
"opera.launcher", a
"opera.port", a
"opera.host", a
"opera.arguments", a
"opera.logging.file", a
"opera.logging.level"]
Browser
_ -> []
getBrowserCaps :: Browser -> Parser Browser
getBrowserCaps Browser
browser =
case Browser
browser of
Firefox {} -> Maybe (PreparedProfile Firefox)
-> LogLevel -> Maybe String -> Maybe Bool -> Browser
Firefox (Maybe (PreparedProfile Firefox)
-> LogLevel -> Maybe String -> Maybe Bool -> Browser)
-> Parser (Maybe (PreparedProfile Firefox))
-> Parser (LogLevel -> Maybe String -> Maybe Bool -> Browser)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Maybe (PreparedProfile Firefox)
-> Parser (Maybe (PreparedProfile Firefox))
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"firefox_profile" Maybe (PreparedProfile Firefox)
forall a. Maybe a
Nothing
Parser (LogLevel -> Maybe String -> Maybe Bool -> Browser)
-> Parser LogLevel
-> Parser (Maybe String -> Maybe Bool -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> LogLevel -> Parser LogLevel
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"loggingPrefs" LogLevel
forall a. Default a => a
def
Parser (Maybe String -> Maybe Bool -> Browser)
-> Parser (Maybe String) -> Parser (Maybe Bool -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"firefox_binary" Maybe String
forall a. Maybe a
Nothing
Parser (Maybe Bool -> Browser)
-> Parser (Maybe Bool) -> Parser Browser
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Bool -> Parser (Maybe Bool)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"acceptInsecureCerts" Maybe Bool
forall a. Maybe a
Nothing
Chrome {} -> Maybe String
-> Maybe String
-> [String]
-> [ChromeExtension]
-> Object
-> Browser
Chrome (Maybe String
-> Maybe String
-> [String]
-> [ChromeExtension]
-> Object
-> Browser)
-> Parser (Maybe String)
-> Parser
(Maybe String
-> [String] -> [ChromeExtension] -> Object -> Browser)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.chromedriverVersion" Maybe String
forall a. Maybe a
Nothing
Parser
(Maybe String
-> [String] -> [ChromeExtension] -> Object -> Browser)
-> Parser (Maybe String)
-> Parser ([String] -> [ChromeExtension] -> Object -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.binary" Maybe String
forall a. Maybe a
Nothing
Parser ([String] -> [ChromeExtension] -> Object -> Browser)
-> Parser [String]
-> Parser ([ChromeExtension] -> Object -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> [String] -> Parser [String]
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.switches" []
Parser ([ChromeExtension] -> Object -> Browser)
-> Parser [ChromeExtension] -> Parser (Object -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> [ChromeExtension] -> Parser [ChromeExtension]
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.extensions" []
Parser (Object -> Browser) -> Parser Object -> Parser Browser
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object -> Parser Object
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Object
forall v. KeyMap v
HM.empty
IE {} -> Bool
-> Bool
-> Maybe Text
-> IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser
IE (Bool
-> Bool
-> Maybe Text
-> IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser Bool
-> Parser
(Bool
-> Maybe Text
-> IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"ignoreProtectedModeSettings" Bool
True
Parser
(Bool
-> Maybe Text
-> IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser Bool
-> Parser
(Maybe Text
-> IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"ignoreZoomSettings" Bool
False
Parser
(Maybe Text
-> IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser (Maybe Text)
-> Parser
(IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Text -> Parser (Maybe Text)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"initialBrowserUrl" Maybe Text
forall a. Maybe a
Nothing
Parser
(IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser IEElementScrollBehavior
-> Parser
(Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> IEElementScrollBehavior -> Parser IEElementScrollBehavior
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"elementScrollBehavior" IEElementScrollBehavior
forall a. Default a => a
def
Parser
(Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser Bool
-> Parser
(Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"enablePersistentHover" Bool
True
Parser
(Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser Bool
-> Parser
(Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"enableElementCacheCleanup" Bool
True
Parser
(Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser Bool
-> Parser
(Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"requireWindowFocus" Bool
False
Parser
(Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser Integer
-> Parser
(Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Integer -> Parser Integer
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"browserAttachTimeout" Integer
0
Parser
(Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser (Maybe String)
-> Parser
(IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"logFile" Maybe String
forall a. Maybe a
Nothing
Parser
(IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser)
-> Parser IELogLevel
-> Parser
(Maybe Text -> Maybe Text -> Bool -> Bool -> Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> IELogLevel -> Parser IELogLevel
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"logLevel" IELogLevel
forall a. Default a => a
def
Parser
(Maybe Text -> Maybe Text -> Bool -> Bool -> Maybe Text -> Browser)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Bool -> Bool -> Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Text -> Parser (Maybe Text)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"host" Maybe Text
forall a. Maybe a
Nothing
Parser (Maybe Text -> Bool -> Bool -> Maybe Text -> Browser)
-> Parser (Maybe Text)
-> Parser (Bool -> Bool -> Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Text -> Parser (Maybe Text)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"extractPath" Maybe Text
forall a. Maybe a
Nothing
Parser (Bool -> Bool -> Maybe Text -> Browser)
-> Parser Bool -> Parser (Bool -> Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"silent" Bool
False
Parser (Bool -> Maybe Text -> Browser)
-> Parser Bool -> Parser (Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"forceCreateProcess" Bool
False
Parser (Maybe Text -> Browser)
-> Parser (Maybe Text) -> Parser Browser
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Text -> Parser (Maybe Text)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"internetExplorerSwitches" Maybe Text
forall a. Maybe a
Nothing
Opera {} -> Maybe String
-> Maybe String
-> Bool
-> Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser
Opera (Maybe String
-> Maybe String
-> Bool
-> Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
-> Parser (Maybe String)
-> Parser
(Maybe String
-> Bool
-> Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.binary" Maybe String
forall a. Maybe a
Nothing
Parser
(Maybe String
-> Bool
-> Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
-> Parser (Maybe String)
-> Parser
(Bool
-> Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.product" Maybe String
forall a. Maybe a
Nothing
Parser
(Bool
-> Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
-> Parser Bool
-> Parser
(Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.no_quit" Bool
False
Parser
(Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
-> Parser Bool
-> Parser
(Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.autostart" Bool
True
Parser
(Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
-> Parser Bool
-> Parser
(Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.idle" Bool
False
Parser
(Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
-> Parser (Maybe Int)
-> Parser
(Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Int -> Parser (Maybe Int)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.display" Maybe Int
forall a. Maybe a
Nothing
Parser
(Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
-> Parser (Maybe String)
-> Parser
(Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.launcher" Maybe String
forall a. Maybe a
Nothing
Parser
(Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser)
-> Parser (Maybe Word16)
-> Parser
(Maybe String
-> Maybe String -> Maybe String -> LogLevel -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Word16 -> Parser (Maybe Word16)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.port" (Word16 -> Maybe Word16
forall a. a -> Maybe a
Just Word16
0)
Parser
(Maybe String
-> Maybe String -> Maybe String -> LogLevel -> Browser)
-> Parser (Maybe String)
-> Parser (Maybe String -> Maybe String -> LogLevel -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.host" Maybe String
forall a. Maybe a
Nothing
Parser (Maybe String -> Maybe String -> LogLevel -> Browser)
-> Parser (Maybe String)
-> Parser (Maybe String -> LogLevel -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.arguments" Maybe String
forall a. Maybe a
Nothing
Parser (Maybe String -> LogLevel -> Browser)
-> Parser (Maybe String) -> Parser (LogLevel -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.logging.file" Maybe String
forall a. Maybe a
Nothing
Parser (LogLevel -> Browser) -> Parser LogLevel -> Parser Browser
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> LogLevel -> Parser LogLevel
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.logging.level" LogLevel
forall a. Default a => a
def
Browser
_ -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
browser
parseJSON Value
v = String -> Value -> Parser Capabilities
forall a. String -> Value -> Parser a
typeMismatch String
"Capabilities" Value
v
data Browser = Firefox {
Browser -> Maybe (PreparedProfile Firefox)
ffProfile :: Maybe (PreparedProfile Firefox)
, Browser -> LogLevel
ffLogPref :: LogLevel
, Browser -> Maybe String
ffBinary :: Maybe FilePath
, Browser -> Maybe Bool
ffAcceptInsecureCerts :: Maybe Bool
}
| Chrome {
Browser -> Maybe String
chromeDriverVersion :: Maybe String
, Browser -> Maybe String
chromeBinary :: Maybe FilePath
, Browser -> [String]
chromeOptions :: [String]
, Browser -> [ChromeExtension]
chromeExtensions :: [ChromeExtension]
, Browser -> Object
chromeExperimentalOptions :: Object
}
| IE {
Browser -> Bool
ieIgnoreProtectedModeSettings :: Bool
, Browser -> Bool
ieIgnoreZoomSetting :: Bool
, Browser -> Maybe Text
ieInitialBrowserUrl :: Maybe Text
, Browser -> IEElementScrollBehavior
ieElementScrollBehavior :: IEElementScrollBehavior
, Browser -> Bool
ieEnablePersistentHover :: Bool
, Browser -> Bool
ieEnableElementCacheCleanup :: Bool
, Browser -> Bool
ieRequireWindowFocus :: Bool
, Browser -> Integer
ieBrowserAttachTimeout :: Integer
, Browser -> Maybe String
ieLogFile :: Maybe FilePath
, Browser -> IELogLevel
ieLogLevel :: IELogLevel
, Browser -> Maybe Text
ieHost :: Maybe Text
, :: Maybe Text
, Browser -> Bool
ieSilent :: Bool
, Browser -> Bool
ieForceCreateProcess :: Bool
, Browser -> Maybe Text
ieSwitches :: Maybe Text
}
| Opera {
Browser -> Maybe String
operaBinary :: Maybe FilePath
, Browser -> Maybe String
operaProduct :: Maybe String
, Browser -> Bool
operaDetach :: Bool
, Browser -> Bool
operaAutoStart :: Bool
, Browser -> Bool
operaIdle :: Bool
, Browser -> Maybe Int
operaDisplay :: Maybe Int
, Browser -> Maybe String
operaLauncher :: Maybe FilePath
, Browser -> Maybe Word16
operaPort :: Maybe Word16
, Browser -> Maybe String
operaHost :: Maybe String
, Browser -> Maybe String
operaOptions :: Maybe String
, Browser -> Maybe String
operaLogFile :: Maybe FilePath
, Browser -> LogLevel
operaLogPref :: LogLevel
}
| Phantomjs { Browser -> Maybe String
phantomjsBinary :: Maybe FilePath
, Browser -> [String]
phantomjsOptions :: [String]
}
| HTMLUnit
| IPhone
| IPad
| Android
| Browser Text
deriving (Browser -> Browser -> Bool
(Browser -> Browser -> Bool)
-> (Browser -> Browser -> Bool) -> Eq Browser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Browser -> Browser -> Bool
== :: Browser -> Browser -> Bool
$c/= :: Browser -> Browser -> Bool
/= :: Browser -> Browser -> Bool
Eq, Int -> Browser -> ShowS
[Browser] -> ShowS
Browser -> String
(Int -> Browser -> ShowS)
-> (Browser -> String) -> ([Browser] -> ShowS) -> Show Browser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Browser -> ShowS
showsPrec :: Int -> Browser -> ShowS
$cshow :: Browser -> String
show :: Browser -> String
$cshowList :: [Browser] -> ShowS
showList :: [Browser] -> ShowS
Show)
instance Default Browser where
def :: Browser
def = Browser
firefox
instance ToJSON Browser where
toJSON :: Browser -> Value
toJSON Firefox {} = Text -> Value
String Text
"firefox"
toJSON Chrome {} = Text -> Value
String Text
"chrome"
toJSON Opera {} = Text -> Value
String Text
"opera"
toJSON IE {} = Text -> Value
String Text
"internet explorer"
toJSON Phantomjs {} = Text -> Value
String Text
"phantomjs"
toJSON (Browser Text
b) = Text -> Value
String Text
b
toJSON Browser
b = Text -> Value
String (Text -> Value) -> (Browser -> Text) -> Browser -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
toLower (Text -> Text) -> (Browser -> Text) -> Browser -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall a. IsString a => String -> a
fromString (String -> Text) -> (Browser -> String) -> Browser -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Browser -> String
forall a. Show a => a -> String
show (Browser -> Value) -> Browser -> Value
forall a b. (a -> b) -> a -> b
$ Browser
b
instance FromJSON Browser where
parseJSON :: Value -> Parser Browser
parseJSON (String Text
jStr) = case Text -> Text
toLower Text
jStr of
Text
"firefox" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
firefox
Text
"chrome" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
chrome
Text
"internet explorer" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
ie
Text
"opera" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
opera
Text
"phantomjs" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
phantomjs
Text
"iphone" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
iPhone
Text
"ipad" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
iPad
Text
"android" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
android
Text
"htmlunit" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
htmlUnit
Text
other -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Browser
Browser Text
other)
parseJSON Value
v = String -> Value -> Parser Browser
forall a. String -> Value -> Parser a
typeMismatch String
"Browser" Value
v
firefox :: Browser
firefox :: Browser
firefox = Maybe (PreparedProfile Firefox)
-> LogLevel -> Maybe String -> Maybe Bool -> Browser
Firefox Maybe (PreparedProfile Firefox)
forall a. Maybe a
Nothing LogLevel
forall a. Default a => a
def Maybe String
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing
chrome :: Browser
chrome :: Browser
chrome = Maybe String
-> Maybe String
-> [String]
-> [ChromeExtension]
-> Object
-> Browser
Chrome Maybe String
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing [] [] Object
forall v. KeyMap v
HM.empty
ie :: Browser
ie :: Browser
ie = IE { ieIgnoreProtectedModeSettings :: Bool
ieIgnoreProtectedModeSettings = Bool
True
, ieIgnoreZoomSetting :: Bool
ieIgnoreZoomSetting = Bool
False
, ieInitialBrowserUrl :: Maybe Text
ieInitialBrowserUrl = Maybe Text
forall a. Maybe a
Nothing
, ieElementScrollBehavior :: IEElementScrollBehavior
ieElementScrollBehavior = IEElementScrollBehavior
forall a. Default a => a
def
, ieEnablePersistentHover :: Bool
ieEnablePersistentHover = Bool
True
, ieEnableElementCacheCleanup :: Bool
ieEnableElementCacheCleanup = Bool
True
, ieRequireWindowFocus :: Bool
ieRequireWindowFocus = Bool
False
, ieBrowserAttachTimeout :: Integer
ieBrowserAttachTimeout = Integer
0
, ieLogFile :: Maybe String
ieLogFile = Maybe String
forall a. Maybe a
Nothing
, ieLogLevel :: IELogLevel
ieLogLevel = IELogLevel
forall a. Default a => a
def
, ieHost :: Maybe Text
ieHost = Maybe Text
forall a. Maybe a
Nothing
, ieExtractPath :: Maybe Text
ieExtractPath = Maybe Text
forall a. Maybe a
Nothing
, ieSilent :: Bool
ieSilent = Bool
False
, ieForceCreateProcess :: Bool
ieForceCreateProcess = Bool
False
, ieSwitches :: Maybe Text
ieSwitches = Maybe Text
forall a. Maybe a
Nothing
}
opera :: Browser
opera :: Browser
opera = Opera { operaBinary :: Maybe String
operaBinary = Maybe String
forall a. Maybe a
Nothing
, operaProduct :: Maybe String
operaProduct = Maybe String
forall a. Maybe a
Nothing
, operaDetach :: Bool
operaDetach = Bool
False
, operaAutoStart :: Bool
operaAutoStart = Bool
True
, operaDisplay :: Maybe Int
operaDisplay = Maybe Int
forall a. Maybe a
Nothing
, operaIdle :: Bool
operaIdle = Bool
False
, operaLauncher :: Maybe String
operaLauncher = Maybe String
forall a. Maybe a
Nothing
, operaHost :: Maybe String
operaHost = Maybe String
forall a. Maybe a
Nothing
, operaPort :: Maybe Word16
operaPort = Word16 -> Maybe Word16
forall a. a -> Maybe a
Just Word16
0
, operaOptions :: Maybe String
operaOptions = Maybe String
forall a. Maybe a
Nothing
, operaLogFile :: Maybe String
operaLogFile = Maybe String
forall a. Maybe a
Nothing
, operaLogPref :: LogLevel
operaLogPref = LogLevel
forall a. Default a => a
def
}
phantomjs :: Browser
phantomjs :: Browser
phantomjs = Maybe String -> [String] -> Browser
Phantomjs Maybe String
forall a. Maybe a
Nothing []
htmlUnit :: Browser
htmlUnit :: Browser
htmlUnit = Browser
HTMLUnit
iPhone :: Browser
iPhone :: Browser
iPhone = Browser
IPhone
iPad :: Browser
iPad :: Browser
iPad = Browser
IPad
android :: Browser
android :: Browser
android = Browser
Android
data Platform = Windows | XP | Vista | Mac | Linux | Unix | Any
deriving (Platform -> Platform -> Bool
(Platform -> Platform -> Bool)
-> (Platform -> Platform -> Bool) -> Eq Platform
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Platform -> Platform -> Bool
== :: Platform -> Platform -> Bool
$c/= :: Platform -> Platform -> Bool
/= :: Platform -> Platform -> Bool
Eq, Int -> Platform -> ShowS
[Platform] -> ShowS
Platform -> String
(Int -> Platform -> ShowS)
-> (Platform -> String) -> ([Platform] -> ShowS) -> Show Platform
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Platform -> ShowS
showsPrec :: Int -> Platform -> ShowS
$cshow :: Platform -> String
show :: Platform -> String
$cshowList :: [Platform] -> ShowS
showList :: [Platform] -> ShowS
Show, Eq Platform
Eq Platform =>
(Platform -> Platform -> Ordering)
-> (Platform -> Platform -> Bool)
-> (Platform -> Platform -> Bool)
-> (Platform -> Platform -> Bool)
-> (Platform -> Platform -> Bool)
-> (Platform -> Platform -> Platform)
-> (Platform -> Platform -> Platform)
-> Ord Platform
Platform -> Platform -> Bool
Platform -> Platform -> Ordering
Platform -> Platform -> Platform
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Platform -> Platform -> Ordering
compare :: Platform -> Platform -> Ordering
$c< :: Platform -> Platform -> Bool
< :: Platform -> Platform -> Bool
$c<= :: Platform -> Platform -> Bool
<= :: Platform -> Platform -> Bool
$c> :: Platform -> Platform -> Bool
> :: Platform -> Platform -> Bool
$c>= :: Platform -> Platform -> Bool
>= :: Platform -> Platform -> Bool
$cmax :: Platform -> Platform -> Platform
max :: Platform -> Platform -> Platform
$cmin :: Platform -> Platform -> Platform
min :: Platform -> Platform -> Platform
Ord, Platform
Platform -> Platform -> Bounded Platform
forall a. a -> a -> Bounded a
$cminBound :: Platform
minBound :: Platform
$cmaxBound :: Platform
maxBound :: Platform
Bounded, Int -> Platform
Platform -> Int
Platform -> [Platform]
Platform -> Platform
Platform -> Platform -> [Platform]
Platform -> Platform -> Platform -> [Platform]
(Platform -> Platform)
-> (Platform -> Platform)
-> (Int -> Platform)
-> (Platform -> Int)
-> (Platform -> [Platform])
-> (Platform -> Platform -> [Platform])
-> (Platform -> Platform -> [Platform])
-> (Platform -> Platform -> Platform -> [Platform])
-> Enum Platform
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Platform -> Platform
succ :: Platform -> Platform
$cpred :: Platform -> Platform
pred :: Platform -> Platform
$ctoEnum :: Int -> Platform
toEnum :: Int -> Platform
$cfromEnum :: Platform -> Int
fromEnum :: Platform -> Int
$cenumFrom :: Platform -> [Platform]
enumFrom :: Platform -> [Platform]
$cenumFromThen :: Platform -> Platform -> [Platform]
enumFromThen :: Platform -> Platform -> [Platform]
$cenumFromTo :: Platform -> Platform -> [Platform]
enumFromTo :: Platform -> Platform -> [Platform]
$cenumFromThenTo :: Platform -> Platform -> Platform -> [Platform]
enumFromThenTo :: Platform -> Platform -> Platform -> [Platform]
Enum)
instance ToJSON Platform where
toJSON :: Platform -> Value
toJSON = Text -> Value
String (Text -> Value) -> (Platform -> Text) -> Platform -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
toUpper (Text -> Text) -> (Platform -> Text) -> Platform -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall a. IsString a => String -> a
fromString (String -> Text) -> (Platform -> String) -> Platform -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Platform -> String
forall a. Show a => a -> String
show
instance FromJSON Platform where
parseJSON :: Value -> Parser Platform
parseJSON (String Text
jStr) = case Text -> Text
toLower Text
jStr of
Text
"windows" -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Windows
Text
"xp" -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
XP
Text
"vista" -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Vista
Text
"mac" -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Mac
Text
"linux" -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Linux
Text
"unix" -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Unix
Text
"any" -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Any
Text
err -> String -> Parser Platform
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Platform) -> String -> Parser Platform
forall a b. (a -> b) -> a -> b
$ String
"Invalid Platform string " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
err
parseJSON Value
v = String -> Value -> Parser Platform
forall a. String -> Value -> Parser a
typeMismatch String
"Platform" Value
v
data ProxyType = NoProxy
| UseSystemSettings
| AutoDetect
| PAC { ProxyType -> String
autoConfigUrl :: String }
| Manual { ProxyType -> String
ftpProxy :: String
, ProxyType -> String
sslProxy :: String
, ProxyType -> String
httpProxy :: String
}
deriving (ProxyType -> ProxyType -> Bool
(ProxyType -> ProxyType -> Bool)
-> (ProxyType -> ProxyType -> Bool) -> Eq ProxyType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProxyType -> ProxyType -> Bool
== :: ProxyType -> ProxyType -> Bool
$c/= :: ProxyType -> ProxyType -> Bool
/= :: ProxyType -> ProxyType -> Bool
Eq, Int -> ProxyType -> ShowS
[ProxyType] -> ShowS
ProxyType -> String
(Int -> ProxyType -> ShowS)
-> (ProxyType -> String)
-> ([ProxyType] -> ShowS)
-> Show ProxyType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProxyType -> ShowS
showsPrec :: Int -> ProxyType -> ShowS
$cshow :: ProxyType -> String
show :: ProxyType -> String
$cshowList :: [ProxyType] -> ShowS
showList :: [ProxyType] -> ShowS
Show)
instance FromJSON ProxyType where
parseJSON :: Value -> Parser ProxyType
parseJSON (Object Object
obj) = do
Text
pTyp <- Text -> Parser Text
forall a. FromJSON a => Text -> Parser a
f Text
"proxyType"
case Text -> Text
toLower Text
pTyp of
Text
"direct" -> ProxyType -> Parser ProxyType
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ProxyType
NoProxy
Text
"system" -> ProxyType -> Parser ProxyType
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ProxyType
UseSystemSettings
Text
"pac" -> String -> ProxyType
PAC (String -> ProxyType) -> Parser String -> Parser ProxyType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Parser String
forall a. FromJSON a => Text -> Parser a
f Text
"autoConfigUrl"
Text
"manual" -> String -> String -> String -> ProxyType
Manual (String -> String -> String -> ProxyType)
-> Parser String -> Parser (String -> String -> ProxyType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Parser String
forall a. FromJSON a => Text -> Parser a
f Text
"ftpProxy"
Parser (String -> String -> ProxyType)
-> Parser String -> Parser (String -> ProxyType)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser String
forall a. FromJSON a => Text -> Parser a
f Text
"sslProxy"
Parser (String -> ProxyType) -> Parser String -> Parser ProxyType
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser String
forall a. FromJSON a => Text -> Parser a
f Text
"httpProxy"
Text
_ -> String -> Parser ProxyType
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ProxyType) -> String -> Parser ProxyType
forall a b. (a -> b) -> a -> b
$ String
"Invalid ProxyType " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
pTyp
where
f :: FromJSON a => Text -> Parser a
f :: forall a. FromJSON a => Text -> Parser a
f = (Object
obj Object -> Key -> Parser a
forall a. FromJSON a => Object -> Key -> Parser a
.:) (Key -> Parser a) -> (Text -> Key) -> Text -> Parser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Key
fromText
parseJSON Value
v = String -> Value -> Parser ProxyType
forall a. String -> Value -> Parser a
typeMismatch String
"ProxyType" Value
v
instance ToJSON ProxyType where
toJSON :: ProxyType -> Value
toJSON ProxyType
pt = [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ case ProxyType
pt of
ProxyType
NoProxy ->
[Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"DIRECT" :: String)]
ProxyType
UseSystemSettings ->
[Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"SYSTEM" :: String)]
ProxyType
AutoDetect ->
[Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"AUTODETECT" :: String)]
PAC{autoConfigUrl :: ProxyType -> String
autoConfigUrl = String
url} ->
[Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"PAC" :: String)
,Key
"proxyAutoconfigUrl" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
url
]
Manual{ftpProxy :: ProxyType -> String
ftpProxy = String
ftp, sslProxy :: ProxyType -> String
sslProxy = String
ssl, httpProxy :: ProxyType -> String
httpProxy = String
http} ->
[Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"MANUAL" :: String)
,Key
"ftpProxy" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
ftp
,Key
"sslProxy" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
ssl
,Key
"httpProxy" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
http
]
data UnexpectedAlertBehavior = AcceptAlert | DismissAlert | IgnoreAlert
deriving (UnexpectedAlertBehavior
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> Bounded UnexpectedAlertBehavior
forall a. a -> a -> Bounded a
$cminBound :: UnexpectedAlertBehavior
minBound :: UnexpectedAlertBehavior
$cmaxBound :: UnexpectedAlertBehavior
maxBound :: UnexpectedAlertBehavior
Bounded, Int -> UnexpectedAlertBehavior
UnexpectedAlertBehavior -> Int
UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
UnexpectedAlertBehavior -> UnexpectedAlertBehavior
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior]
(UnexpectedAlertBehavior -> UnexpectedAlertBehavior)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior)
-> (Int -> UnexpectedAlertBehavior)
-> (UnexpectedAlertBehavior -> Int)
-> (UnexpectedAlertBehavior -> [UnexpectedAlertBehavior])
-> (UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior])
-> (UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior])
-> (UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior])
-> Enum UnexpectedAlertBehavior
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
succ :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$cpred :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
pred :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$ctoEnum :: Int -> UnexpectedAlertBehavior
toEnum :: Int -> UnexpectedAlertBehavior
$cfromEnum :: UnexpectedAlertBehavior -> Int
fromEnum :: UnexpectedAlertBehavior -> Int
$cenumFrom :: UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
enumFrom :: UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
$cenumFromThen :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
enumFromThen :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
$cenumFromTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
enumFromTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
$cenumFromThenTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior]
enumFromThenTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior]
Enum, UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
(UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> Eq UnexpectedAlertBehavior
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
== :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c/= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
/= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
Eq, Eq UnexpectedAlertBehavior
Eq UnexpectedAlertBehavior =>
(UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior)
-> (UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior)
-> Ord UnexpectedAlertBehavior
UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering
compare :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering
$c< :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
< :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c<= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
<= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c> :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
> :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c>= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
>= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$cmax :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
max :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$cmin :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
min :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
Ord, ReadPrec [UnexpectedAlertBehavior]
ReadPrec UnexpectedAlertBehavior
Int -> ReadS UnexpectedAlertBehavior
ReadS [UnexpectedAlertBehavior]
(Int -> ReadS UnexpectedAlertBehavior)
-> ReadS [UnexpectedAlertBehavior]
-> ReadPrec UnexpectedAlertBehavior
-> ReadPrec [UnexpectedAlertBehavior]
-> Read UnexpectedAlertBehavior
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS UnexpectedAlertBehavior
readsPrec :: Int -> ReadS UnexpectedAlertBehavior
$creadList :: ReadS [UnexpectedAlertBehavior]
readList :: ReadS [UnexpectedAlertBehavior]
$creadPrec :: ReadPrec UnexpectedAlertBehavior
readPrec :: ReadPrec UnexpectedAlertBehavior
$creadListPrec :: ReadPrec [UnexpectedAlertBehavior]
readListPrec :: ReadPrec [UnexpectedAlertBehavior]
Read, Int -> UnexpectedAlertBehavior -> ShowS
[UnexpectedAlertBehavior] -> ShowS
UnexpectedAlertBehavior -> String
(Int -> UnexpectedAlertBehavior -> ShowS)
-> (UnexpectedAlertBehavior -> String)
-> ([UnexpectedAlertBehavior] -> ShowS)
-> Show UnexpectedAlertBehavior
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UnexpectedAlertBehavior -> ShowS
showsPrec :: Int -> UnexpectedAlertBehavior -> ShowS
$cshow :: UnexpectedAlertBehavior -> String
show :: UnexpectedAlertBehavior -> String
$cshowList :: [UnexpectedAlertBehavior] -> ShowS
showList :: [UnexpectedAlertBehavior] -> ShowS
Show)
instance ToJSON UnexpectedAlertBehavior where
toJSON :: UnexpectedAlertBehavior -> Value
toJSON UnexpectedAlertBehavior
AcceptAlert = Text -> Value
String Text
"accept"
toJSON UnexpectedAlertBehavior
DismissAlert = Text -> Value
String Text
"dismiss"
toJSON UnexpectedAlertBehavior
IgnoreAlert = Text -> Value
String Text
"ignore"
instance FromJSON UnexpectedAlertBehavior where
parseJSON :: Value -> Parser UnexpectedAlertBehavior
parseJSON (String Text
s) =
UnexpectedAlertBehavior -> Parser UnexpectedAlertBehavior
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (UnexpectedAlertBehavior -> Parser UnexpectedAlertBehavior)
-> UnexpectedAlertBehavior -> Parser UnexpectedAlertBehavior
forall a b. (a -> b) -> a -> b
$ case Text
s of
Text
"accept" -> UnexpectedAlertBehavior
AcceptAlert
Text
"dismiss" -> UnexpectedAlertBehavior
DismissAlert
Text
"ignore" -> UnexpectedAlertBehavior
IgnoreAlert
Text
err -> BadJSON -> UnexpectedAlertBehavior
forall a e. Exception e => e -> a
throw (BadJSON -> UnexpectedAlertBehavior)
-> (String -> BadJSON) -> String -> UnexpectedAlertBehavior
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> BadJSON
BadJSON
(String -> UnexpectedAlertBehavior)
-> String -> UnexpectedAlertBehavior
forall a b. (a -> b) -> a -> b
$ String
"Invalid string value for UnexpectedAlertBehavior: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
err
parseJSON Value
v = String -> Value -> Parser UnexpectedAlertBehavior
forall a. String -> Value -> Parser a
typeMismatch String
"UnexpectedAlertBehavior" Value
v
data LogLevel = LogOff | LogSevere | LogWarning | LogInfo | LogConfig
| LogFine | LogFiner | LogFinest | LogDebug | LogAll
deriving (LogLevel -> LogLevel -> Bool
(LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> Bool) -> Eq LogLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LogLevel -> LogLevel -> Bool
== :: LogLevel -> LogLevel -> Bool
$c/= :: LogLevel -> LogLevel -> Bool
/= :: LogLevel -> LogLevel -> Bool
Eq, Int -> LogLevel -> ShowS
[LogLevel] -> ShowS
LogLevel -> String
(Int -> LogLevel -> ShowS)
-> (LogLevel -> String) -> ([LogLevel] -> ShowS) -> Show LogLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LogLevel -> ShowS
showsPrec :: Int -> LogLevel -> ShowS
$cshow :: LogLevel -> String
show :: LogLevel -> String
$cshowList :: [LogLevel] -> ShowS
showList :: [LogLevel] -> ShowS
Show, ReadPrec [LogLevel]
ReadPrec LogLevel
Int -> ReadS LogLevel
ReadS [LogLevel]
(Int -> ReadS LogLevel)
-> ReadS [LogLevel]
-> ReadPrec LogLevel
-> ReadPrec [LogLevel]
-> Read LogLevel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS LogLevel
readsPrec :: Int -> ReadS LogLevel
$creadList :: ReadS [LogLevel]
readList :: ReadS [LogLevel]
$creadPrec :: ReadPrec LogLevel
readPrec :: ReadPrec LogLevel
$creadListPrec :: ReadPrec [LogLevel]
readListPrec :: ReadPrec [LogLevel]
Read, Eq LogLevel
Eq LogLevel =>
(LogLevel -> LogLevel -> Ordering)
-> (LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> LogLevel)
-> (LogLevel -> LogLevel -> LogLevel)
-> Ord LogLevel
LogLevel -> LogLevel -> Bool
LogLevel -> LogLevel -> Ordering
LogLevel -> LogLevel -> LogLevel
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: LogLevel -> LogLevel -> Ordering
compare :: LogLevel -> LogLevel -> Ordering
$c< :: LogLevel -> LogLevel -> Bool
< :: LogLevel -> LogLevel -> Bool
$c<= :: LogLevel -> LogLevel -> Bool
<= :: LogLevel -> LogLevel -> Bool
$c> :: LogLevel -> LogLevel -> Bool
> :: LogLevel -> LogLevel -> Bool
$c>= :: LogLevel -> LogLevel -> Bool
>= :: LogLevel -> LogLevel -> Bool
$cmax :: LogLevel -> LogLevel -> LogLevel
max :: LogLevel -> LogLevel -> LogLevel
$cmin :: LogLevel -> LogLevel -> LogLevel
min :: LogLevel -> LogLevel -> LogLevel
Ord, LogLevel
LogLevel -> LogLevel -> Bounded LogLevel
forall a. a -> a -> Bounded a
$cminBound :: LogLevel
minBound :: LogLevel
$cmaxBound :: LogLevel
maxBound :: LogLevel
Bounded, Int -> LogLevel
LogLevel -> Int
LogLevel -> [LogLevel]
LogLevel -> LogLevel
LogLevel -> LogLevel -> [LogLevel]
LogLevel -> LogLevel -> LogLevel -> [LogLevel]
(LogLevel -> LogLevel)
-> (LogLevel -> LogLevel)
-> (Int -> LogLevel)
-> (LogLevel -> Int)
-> (LogLevel -> [LogLevel])
-> (LogLevel -> LogLevel -> [LogLevel])
-> (LogLevel -> LogLevel -> [LogLevel])
-> (LogLevel -> LogLevel -> LogLevel -> [LogLevel])
-> Enum LogLevel
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: LogLevel -> LogLevel
succ :: LogLevel -> LogLevel
$cpred :: LogLevel -> LogLevel
pred :: LogLevel -> LogLevel
$ctoEnum :: Int -> LogLevel
toEnum :: Int -> LogLevel
$cfromEnum :: LogLevel -> Int
fromEnum :: LogLevel -> Int
$cenumFrom :: LogLevel -> [LogLevel]
enumFrom :: LogLevel -> [LogLevel]
$cenumFromThen :: LogLevel -> LogLevel -> [LogLevel]
enumFromThen :: LogLevel -> LogLevel -> [LogLevel]
$cenumFromTo :: LogLevel -> LogLevel -> [LogLevel]
enumFromTo :: LogLevel -> LogLevel -> [LogLevel]
$cenumFromThenTo :: LogLevel -> LogLevel -> LogLevel -> [LogLevel]
enumFromThenTo :: LogLevel -> LogLevel -> LogLevel -> [LogLevel]
Enum)
instance Default LogLevel where
def :: LogLevel
def = LogLevel
LogInfo
instance ToJSON LogLevel where
toJSON :: LogLevel -> Value
toJSON LogLevel
p= Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ case LogLevel
p of
LogLevel
LogOff -> Text
"OFF"
LogLevel
LogSevere -> Text
"SEVERE"
LogLevel
LogWarning -> Text
"WARNING"
LogLevel
LogInfo -> Text
"INFO"
LogLevel
LogConfig -> Text
"CONFIG"
LogLevel
LogFine -> Text
"FINE"
LogLevel
LogFiner -> Text
"FINER"
LogLevel
LogFinest -> Text
"FINEST"
LogLevel
LogDebug -> Text
"DEBUG"
LogLevel
LogAll -> Text
"ALL"
instance FromJSON LogLevel where
parseJSON :: Value -> Parser LogLevel
parseJSON (String Text
s) = LogLevel -> Parser LogLevel
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (LogLevel -> Parser LogLevel) -> LogLevel -> Parser LogLevel
forall a b. (a -> b) -> a -> b
$ case Text
s of
Text
"OFF" -> LogLevel
LogOff
Text
"SEVERE" -> LogLevel
LogSevere
Text
"WARNING" -> LogLevel
LogWarning
Text
"INFO" -> LogLevel
LogInfo
Text
"CONFIG" -> LogLevel
LogConfig
Text
"FINE" -> LogLevel
LogFine
Text
"FINER" -> LogLevel
LogFiner
Text
"FINEST" -> LogLevel
LogFinest
Text
"DEBUG" -> LogLevel
LogDebug
Text
"ALL" -> LogLevel
LogAll
Text
_ -> BadJSON -> LogLevel
forall a e. Exception e => e -> a
throw (BadJSON -> LogLevel) -> (String -> BadJSON) -> String -> LogLevel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> BadJSON
BadJSON (String -> LogLevel) -> String -> LogLevel
forall a b. (a -> b) -> a -> b
$ String
"Invalid logging preference: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
s
parseJSON Value
other = String -> Value -> Parser LogLevel
forall a. String -> Value -> Parser a
typeMismatch String
"LogLevel" Value
other
data IELogLevel = IELogTrace | IELogDebug | IELogInfo | IELogWarn | IELogError
| IELogFatal
deriving (IELogLevel -> IELogLevel -> Bool
(IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> Bool) -> Eq IELogLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IELogLevel -> IELogLevel -> Bool
== :: IELogLevel -> IELogLevel -> Bool
$c/= :: IELogLevel -> IELogLevel -> Bool
/= :: IELogLevel -> IELogLevel -> Bool
Eq, Int -> IELogLevel -> ShowS
[IELogLevel] -> ShowS
IELogLevel -> String
(Int -> IELogLevel -> ShowS)
-> (IELogLevel -> String)
-> ([IELogLevel] -> ShowS)
-> Show IELogLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IELogLevel -> ShowS
showsPrec :: Int -> IELogLevel -> ShowS
$cshow :: IELogLevel -> String
show :: IELogLevel -> String
$cshowList :: [IELogLevel] -> ShowS
showList :: [IELogLevel] -> ShowS
Show, ReadPrec [IELogLevel]
ReadPrec IELogLevel
Int -> ReadS IELogLevel
ReadS [IELogLevel]
(Int -> ReadS IELogLevel)
-> ReadS [IELogLevel]
-> ReadPrec IELogLevel
-> ReadPrec [IELogLevel]
-> Read IELogLevel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS IELogLevel
readsPrec :: Int -> ReadS IELogLevel
$creadList :: ReadS [IELogLevel]
readList :: ReadS [IELogLevel]
$creadPrec :: ReadPrec IELogLevel
readPrec :: ReadPrec IELogLevel
$creadListPrec :: ReadPrec [IELogLevel]
readListPrec :: ReadPrec [IELogLevel]
Read, Eq IELogLevel
Eq IELogLevel =>
(IELogLevel -> IELogLevel -> Ordering)
-> (IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> IELogLevel)
-> (IELogLevel -> IELogLevel -> IELogLevel)
-> Ord IELogLevel
IELogLevel -> IELogLevel -> Bool
IELogLevel -> IELogLevel -> Ordering
IELogLevel -> IELogLevel -> IELogLevel
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: IELogLevel -> IELogLevel -> Ordering
compare :: IELogLevel -> IELogLevel -> Ordering
$c< :: IELogLevel -> IELogLevel -> Bool
< :: IELogLevel -> IELogLevel -> Bool
$c<= :: IELogLevel -> IELogLevel -> Bool
<= :: IELogLevel -> IELogLevel -> Bool
$c> :: IELogLevel -> IELogLevel -> Bool
> :: IELogLevel -> IELogLevel -> Bool
$c>= :: IELogLevel -> IELogLevel -> Bool
>= :: IELogLevel -> IELogLevel -> Bool
$cmax :: IELogLevel -> IELogLevel -> IELogLevel
max :: IELogLevel -> IELogLevel -> IELogLevel
$cmin :: IELogLevel -> IELogLevel -> IELogLevel
min :: IELogLevel -> IELogLevel -> IELogLevel
Ord, IELogLevel
IELogLevel -> IELogLevel -> Bounded IELogLevel
forall a. a -> a -> Bounded a
$cminBound :: IELogLevel
minBound :: IELogLevel
$cmaxBound :: IELogLevel
maxBound :: IELogLevel
Bounded, Int -> IELogLevel
IELogLevel -> Int
IELogLevel -> [IELogLevel]
IELogLevel -> IELogLevel
IELogLevel -> IELogLevel -> [IELogLevel]
IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel]
(IELogLevel -> IELogLevel)
-> (IELogLevel -> IELogLevel)
-> (Int -> IELogLevel)
-> (IELogLevel -> Int)
-> (IELogLevel -> [IELogLevel])
-> (IELogLevel -> IELogLevel -> [IELogLevel])
-> (IELogLevel -> IELogLevel -> [IELogLevel])
-> (IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel])
-> Enum IELogLevel
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: IELogLevel -> IELogLevel
succ :: IELogLevel -> IELogLevel
$cpred :: IELogLevel -> IELogLevel
pred :: IELogLevel -> IELogLevel
$ctoEnum :: Int -> IELogLevel
toEnum :: Int -> IELogLevel
$cfromEnum :: IELogLevel -> Int
fromEnum :: IELogLevel -> Int
$cenumFrom :: IELogLevel -> [IELogLevel]
enumFrom :: IELogLevel -> [IELogLevel]
$cenumFromThen :: IELogLevel -> IELogLevel -> [IELogLevel]
enumFromThen :: IELogLevel -> IELogLevel -> [IELogLevel]
$cenumFromTo :: IELogLevel -> IELogLevel -> [IELogLevel]
enumFromTo :: IELogLevel -> IELogLevel -> [IELogLevel]
$cenumFromThenTo :: IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel]
enumFromThenTo :: IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel]
Enum)
instance Default IELogLevel where
def :: IELogLevel
def = IELogLevel
IELogFatal
instance ToJSON IELogLevel where
toJSON :: IELogLevel -> Value
toJSON IELogLevel
p= Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ case IELogLevel
p of
IELogLevel
IELogTrace -> Text
"TRACE"
IELogLevel
IELogDebug -> Text
"DEBUG"
IELogLevel
IELogInfo -> Text
"INFO"
IELogLevel
IELogWarn -> Text
"WARN"
IELogLevel
IELogError -> Text
"ERROR"
IELogLevel
IELogFatal -> Text
"FATAL"
instance FromJSON IELogLevel where
parseJSON :: Value -> Parser IELogLevel
parseJSON (String Text
s) = IELogLevel -> Parser IELogLevel
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (IELogLevel -> Parser IELogLevel)
-> IELogLevel -> Parser IELogLevel
forall a b. (a -> b) -> a -> b
$ case Text
s of
Text
"TRACE" -> IELogLevel
IELogTrace
Text
"DEBIG" -> IELogLevel
IELogDebug
Text
"INFO" -> IELogLevel
IELogInfo
Text
"WARN" -> IELogLevel
IELogWarn
Text
"ERROR" -> IELogLevel
IELogError
Text
"FATAL" -> IELogLevel
IELogFatal
Text
_ -> BadJSON -> IELogLevel
forall a e. Exception e => e -> a
throw (BadJSON -> IELogLevel)
-> (String -> BadJSON) -> String -> IELogLevel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> BadJSON
BadJSON (String -> IELogLevel) -> String -> IELogLevel
forall a b. (a -> b) -> a -> b
$ String
"Invalid logging preference: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
s
parseJSON Value
other = String -> Value -> Parser IELogLevel
forall a. String -> Value -> Parser a
typeMismatch String
"IELogLevel" Value
other
data IEElementScrollBehavior = AlignTop | AlignBottom
deriving (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
(IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> Eq IEElementScrollBehavior
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
== :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c/= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
/= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
Eq, Eq IEElementScrollBehavior
Eq IEElementScrollBehavior =>
(IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior)
-> (IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior)
-> Ord IEElementScrollBehavior
IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering
IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering
compare :: IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering
$c< :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
< :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c<= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
<= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c> :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
> :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c>= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
>= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$cmax :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
max :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
$cmin :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
min :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
Ord, Int -> IEElementScrollBehavior -> ShowS
[IEElementScrollBehavior] -> ShowS
IEElementScrollBehavior -> String
(Int -> IEElementScrollBehavior -> ShowS)
-> (IEElementScrollBehavior -> String)
-> ([IEElementScrollBehavior] -> ShowS)
-> Show IEElementScrollBehavior
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IEElementScrollBehavior -> ShowS
showsPrec :: Int -> IEElementScrollBehavior -> ShowS
$cshow :: IEElementScrollBehavior -> String
show :: IEElementScrollBehavior -> String
$cshowList :: [IEElementScrollBehavior] -> ShowS
showList :: [IEElementScrollBehavior] -> ShowS
Show, ReadPrec [IEElementScrollBehavior]
ReadPrec IEElementScrollBehavior
Int -> ReadS IEElementScrollBehavior
ReadS [IEElementScrollBehavior]
(Int -> ReadS IEElementScrollBehavior)
-> ReadS [IEElementScrollBehavior]
-> ReadPrec IEElementScrollBehavior
-> ReadPrec [IEElementScrollBehavior]
-> Read IEElementScrollBehavior
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS IEElementScrollBehavior
readsPrec :: Int -> ReadS IEElementScrollBehavior
$creadList :: ReadS [IEElementScrollBehavior]
readList :: ReadS [IEElementScrollBehavior]
$creadPrec :: ReadPrec IEElementScrollBehavior
readPrec :: ReadPrec IEElementScrollBehavior
$creadListPrec :: ReadPrec [IEElementScrollBehavior]
readListPrec :: ReadPrec [IEElementScrollBehavior]
Read, Int -> IEElementScrollBehavior
IEElementScrollBehavior -> Int
IEElementScrollBehavior -> [IEElementScrollBehavior]
IEElementScrollBehavior -> IEElementScrollBehavior
IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior]
(IEElementScrollBehavior -> IEElementScrollBehavior)
-> (IEElementScrollBehavior -> IEElementScrollBehavior)
-> (Int -> IEElementScrollBehavior)
-> (IEElementScrollBehavior -> Int)
-> (IEElementScrollBehavior -> [IEElementScrollBehavior])
-> (IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior])
-> (IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior])
-> (IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior])
-> Enum IEElementScrollBehavior
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: IEElementScrollBehavior -> IEElementScrollBehavior
succ :: IEElementScrollBehavior -> IEElementScrollBehavior
$cpred :: IEElementScrollBehavior -> IEElementScrollBehavior
pred :: IEElementScrollBehavior -> IEElementScrollBehavior
$ctoEnum :: Int -> IEElementScrollBehavior
toEnum :: Int -> IEElementScrollBehavior
$cfromEnum :: IEElementScrollBehavior -> Int
fromEnum :: IEElementScrollBehavior -> Int
$cenumFrom :: IEElementScrollBehavior -> [IEElementScrollBehavior]
enumFrom :: IEElementScrollBehavior -> [IEElementScrollBehavior]
$cenumFromThen :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
enumFromThen :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
$cenumFromTo :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
enumFromTo :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
$cenumFromThenTo :: IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior]
enumFromThenTo :: IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior]
Enum, IEElementScrollBehavior
IEElementScrollBehavior
-> IEElementScrollBehavior -> Bounded IEElementScrollBehavior
forall a. a -> a -> Bounded a
$cminBound :: IEElementScrollBehavior
minBound :: IEElementScrollBehavior
$cmaxBound :: IEElementScrollBehavior
maxBound :: IEElementScrollBehavior
Bounded)
instance Default IEElementScrollBehavior where
def :: IEElementScrollBehavior
def = IEElementScrollBehavior
AlignTop
instance ToJSON IEElementScrollBehavior where
toJSON :: IEElementScrollBehavior -> Value
toJSON IEElementScrollBehavior
AlignTop = Int -> Value
forall a. ToJSON a => a -> Value
toJSON (Int
0 :: Int)
toJSON IEElementScrollBehavior
AlignBottom = Int -> Value
forall a. ToJSON a => a -> Value
toJSON (Int
1 :: Int)
instance FromJSON IEElementScrollBehavior where
parseJSON :: Value -> Parser IEElementScrollBehavior
parseJSON Value
v = do
Integer
n <- Value -> Parser Integer
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
case Integer
n :: Integer of
Integer
0 -> IEElementScrollBehavior -> Parser IEElementScrollBehavior
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return IEElementScrollBehavior
AlignTop
Integer
1 -> IEElementScrollBehavior -> Parser IEElementScrollBehavior
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return IEElementScrollBehavior
AlignBottom
Integer
_ -> String -> Parser IEElementScrollBehavior
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser IEElementScrollBehavior)
-> String -> Parser IEElementScrollBehavior
forall a b. (a -> b) -> a -> b
$ String
"Invalid integer for IEElementScrollBehavior: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
n