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