{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

module Stack.Types.ApplyGhcOptions
  ( ApplyGhcOptions (..)
  ) where

import           Pantry.Internal.AesonExtended ( FromJSON (..), withText )
import           Stack.Prelude

-- | Which packages do ghc-options on the command line apply to?

data ApplyGhcOptions
  = AGOTargets -- ^ all local targets

  | AGOLocals -- ^ all local packages, even non-targets

  | AGOEverything -- ^ every package

  deriving (ApplyGhcOptions
forall a. a -> a -> Bounded a
maxBound :: ApplyGhcOptions
$cmaxBound :: ApplyGhcOptions
minBound :: ApplyGhcOptions
$cminBound :: ApplyGhcOptions
Bounded, Int -> ApplyGhcOptions
ApplyGhcOptions -> Int
ApplyGhcOptions -> [ApplyGhcOptions]
ApplyGhcOptions -> ApplyGhcOptions
ApplyGhcOptions -> ApplyGhcOptions -> [ApplyGhcOptions]
ApplyGhcOptions
-> ApplyGhcOptions -> ApplyGhcOptions -> [ApplyGhcOptions]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: ApplyGhcOptions
-> ApplyGhcOptions -> ApplyGhcOptions -> [ApplyGhcOptions]
$cenumFromThenTo :: ApplyGhcOptions
-> ApplyGhcOptions -> ApplyGhcOptions -> [ApplyGhcOptions]
enumFromTo :: ApplyGhcOptions -> ApplyGhcOptions -> [ApplyGhcOptions]
$cenumFromTo :: ApplyGhcOptions -> ApplyGhcOptions -> [ApplyGhcOptions]
enumFromThen :: ApplyGhcOptions -> ApplyGhcOptions -> [ApplyGhcOptions]
$cenumFromThen :: ApplyGhcOptions -> ApplyGhcOptions -> [ApplyGhcOptions]
enumFrom :: ApplyGhcOptions -> [ApplyGhcOptions]
$cenumFrom :: ApplyGhcOptions -> [ApplyGhcOptions]
fromEnum :: ApplyGhcOptions -> Int
$cfromEnum :: ApplyGhcOptions -> Int
toEnum :: Int -> ApplyGhcOptions
$ctoEnum :: Int -> ApplyGhcOptions
pred :: ApplyGhcOptions -> ApplyGhcOptions
$cpred :: ApplyGhcOptions -> ApplyGhcOptions
succ :: ApplyGhcOptions -> ApplyGhcOptions
$csucc :: ApplyGhcOptions -> ApplyGhcOptions
Enum, ApplyGhcOptions -> ApplyGhcOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
$c/= :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
== :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
$c== :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
Eq, Eq ApplyGhcOptions
ApplyGhcOptions -> ApplyGhcOptions -> Bool
ApplyGhcOptions -> ApplyGhcOptions -> Ordering
ApplyGhcOptions -> ApplyGhcOptions -> ApplyGhcOptions
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
min :: ApplyGhcOptions -> ApplyGhcOptions -> ApplyGhcOptions
$cmin :: ApplyGhcOptions -> ApplyGhcOptions -> ApplyGhcOptions
max :: ApplyGhcOptions -> ApplyGhcOptions -> ApplyGhcOptions
$cmax :: ApplyGhcOptions -> ApplyGhcOptions -> ApplyGhcOptions
>= :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
$c>= :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
> :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
$c> :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
<= :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
$c<= :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
< :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
$c< :: ApplyGhcOptions -> ApplyGhcOptions -> Bool
compare :: ApplyGhcOptions -> ApplyGhcOptions -> Ordering
$ccompare :: ApplyGhcOptions -> ApplyGhcOptions -> Ordering
Ord, ReadPrec [ApplyGhcOptions]
ReadPrec ApplyGhcOptions
Int -> ReadS ApplyGhcOptions
ReadS [ApplyGhcOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplyGhcOptions]
$creadListPrec :: ReadPrec [ApplyGhcOptions]
readPrec :: ReadPrec ApplyGhcOptions
$creadPrec :: ReadPrec ApplyGhcOptions
readList :: ReadS [ApplyGhcOptions]
$creadList :: ReadS [ApplyGhcOptions]
readsPrec :: Int -> ReadS ApplyGhcOptions
$creadsPrec :: Int -> ReadS ApplyGhcOptions
Read, Int -> ApplyGhcOptions -> ShowS
[ApplyGhcOptions] -> ShowS
ApplyGhcOptions -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [ApplyGhcOptions] -> ShowS
$cshowList :: [ApplyGhcOptions] -> ShowS
show :: ApplyGhcOptions -> [Char]
$cshow :: ApplyGhcOptions -> [Char]
showsPrec :: Int -> ApplyGhcOptions -> ShowS
$cshowsPrec :: Int -> ApplyGhcOptions -> ShowS
Show)

instance FromJSON ApplyGhcOptions where
  parseJSON :: Value -> Parser ApplyGhcOptions
parseJSON = forall a. [Char] -> (Text -> Parser a) -> Value -> Parser a
withText [Char]
"ApplyGhcOptions" forall a b. (a -> b) -> a -> b
$ \Text
t ->
    case Text
t of
      Text
"targets" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ApplyGhcOptions
AGOTargets
      Text
"locals" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ApplyGhcOptions
AGOLocals
      Text
"everything" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ApplyGhcOptions
AGOEverything
      Text
_ -> forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail forall a b. (a -> b) -> a -> b
$ [Char]
"Invalid ApplyGhcOptions: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show Text
t