{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module Stack.Types.DumpLogs
( DumpLogs (..)
) where
import Data.Aeson.Types ( FromJSON (..), Value (..), withText )
import Stack.Prelude
data DumpLogs
= DumpNoLogs
| DumpWarningLogs
| DumpAllLogs
deriving (DumpLogs
DumpLogs -> DumpLogs -> Bounded DumpLogs
forall a. a -> a -> Bounded a
$cminBound :: DumpLogs
minBound :: DumpLogs
$cmaxBound :: DumpLogs
maxBound :: DumpLogs
Bounded, Int -> DumpLogs
DumpLogs -> Int
DumpLogs -> [DumpLogs]
DumpLogs -> DumpLogs
DumpLogs -> DumpLogs -> [DumpLogs]
DumpLogs -> DumpLogs -> DumpLogs -> [DumpLogs]
(DumpLogs -> DumpLogs)
-> (DumpLogs -> DumpLogs)
-> (Int -> DumpLogs)
-> (DumpLogs -> Int)
-> (DumpLogs -> [DumpLogs])
-> (DumpLogs -> DumpLogs -> [DumpLogs])
-> (DumpLogs -> DumpLogs -> [DumpLogs])
-> (DumpLogs -> DumpLogs -> DumpLogs -> [DumpLogs])
-> Enum DumpLogs
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 :: DumpLogs -> DumpLogs
succ :: DumpLogs -> DumpLogs
$cpred :: DumpLogs -> DumpLogs
pred :: DumpLogs -> DumpLogs
$ctoEnum :: Int -> DumpLogs
toEnum :: Int -> DumpLogs
$cfromEnum :: DumpLogs -> Int
fromEnum :: DumpLogs -> Int
$cenumFrom :: DumpLogs -> [DumpLogs]
enumFrom :: DumpLogs -> [DumpLogs]
$cenumFromThen :: DumpLogs -> DumpLogs -> [DumpLogs]
enumFromThen :: DumpLogs -> DumpLogs -> [DumpLogs]
$cenumFromTo :: DumpLogs -> DumpLogs -> [DumpLogs]
enumFromTo :: DumpLogs -> DumpLogs -> [DumpLogs]
$cenumFromThenTo :: DumpLogs -> DumpLogs -> DumpLogs -> [DumpLogs]
enumFromThenTo :: DumpLogs -> DumpLogs -> DumpLogs -> [DumpLogs]
Enum, DumpLogs -> DumpLogs -> Bool
(DumpLogs -> DumpLogs -> Bool)
-> (DumpLogs -> DumpLogs -> Bool) -> Eq DumpLogs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DumpLogs -> DumpLogs -> Bool
== :: DumpLogs -> DumpLogs -> Bool
$c/= :: DumpLogs -> DumpLogs -> Bool
/= :: DumpLogs -> DumpLogs -> Bool
Eq, Eq DumpLogs
Eq DumpLogs
-> (DumpLogs -> DumpLogs -> Ordering)
-> (DumpLogs -> DumpLogs -> Bool)
-> (DumpLogs -> DumpLogs -> Bool)
-> (DumpLogs -> DumpLogs -> Bool)
-> (DumpLogs -> DumpLogs -> Bool)
-> (DumpLogs -> DumpLogs -> DumpLogs)
-> (DumpLogs -> DumpLogs -> DumpLogs)
-> Ord DumpLogs
DumpLogs -> DumpLogs -> Bool
DumpLogs -> DumpLogs -> Ordering
DumpLogs -> DumpLogs -> DumpLogs
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 :: DumpLogs -> DumpLogs -> Ordering
compare :: DumpLogs -> DumpLogs -> Ordering
$c< :: DumpLogs -> DumpLogs -> Bool
< :: DumpLogs -> DumpLogs -> Bool
$c<= :: DumpLogs -> DumpLogs -> Bool
<= :: DumpLogs -> DumpLogs -> Bool
$c> :: DumpLogs -> DumpLogs -> Bool
> :: DumpLogs -> DumpLogs -> Bool
$c>= :: DumpLogs -> DumpLogs -> Bool
>= :: DumpLogs -> DumpLogs -> Bool
$cmax :: DumpLogs -> DumpLogs -> DumpLogs
max :: DumpLogs -> DumpLogs -> DumpLogs
$cmin :: DumpLogs -> DumpLogs -> DumpLogs
min :: DumpLogs -> DumpLogs -> DumpLogs
Ord, ReadPrec [DumpLogs]
ReadPrec DumpLogs
Int -> ReadS DumpLogs
ReadS [DumpLogs]
(Int -> ReadS DumpLogs)
-> ReadS [DumpLogs]
-> ReadPrec DumpLogs
-> ReadPrec [DumpLogs]
-> Read DumpLogs
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DumpLogs
readsPrec :: Int -> ReadS DumpLogs
$creadList :: ReadS [DumpLogs]
readList :: ReadS [DumpLogs]
$creadPrec :: ReadPrec DumpLogs
readPrec :: ReadPrec DumpLogs
$creadListPrec :: ReadPrec [DumpLogs]
readListPrec :: ReadPrec [DumpLogs]
Read, Int -> DumpLogs -> ShowS
[DumpLogs] -> ShowS
DumpLogs -> [Char]
(Int -> DumpLogs -> ShowS)
-> (DumpLogs -> [Char]) -> ([DumpLogs] -> ShowS) -> Show DumpLogs
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DumpLogs -> ShowS
showsPrec :: Int -> DumpLogs -> ShowS
$cshow :: DumpLogs -> [Char]
show :: DumpLogs -> [Char]
$cshowList :: [DumpLogs] -> ShowS
showList :: [DumpLogs] -> ShowS
Show)
instance FromJSON DumpLogs where
parseJSON :: Value -> Parser DumpLogs
parseJSON (Bool Bool
True) = DumpLogs -> Parser DumpLogs
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DumpLogs
DumpAllLogs
parseJSON (Bool Bool
False) = DumpLogs -> Parser DumpLogs
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DumpLogs
DumpNoLogs
parseJSON Value
v =
[Char] -> (Text -> Parser DumpLogs) -> Value -> Parser DumpLogs
forall a. [Char] -> (Text -> Parser a) -> Value -> Parser a
withText
[Char]
"DumpLogs"
(\Text
t ->
if | Text
t Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"none" -> DumpLogs -> Parser DumpLogs
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DumpLogs
DumpNoLogs
| Text
t Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"warning" -> DumpLogs -> Parser DumpLogs
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DumpLogs
DumpWarningLogs
| Text
t Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"all" -> DumpLogs -> Parser DumpLogs
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DumpLogs
DumpAllLogs
| Bool
otherwise -> [Char] -> Parser DumpLogs
forall a. [Char] -> Parser a
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail ([Char]
"Invalid DumpLogs: " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> [Char]
forall a. Show a => a -> [Char]
show Text
t))
Value
v