{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} module Stack.Types.GhcOptionKey ( GhcOptionKey (..) ) where import qualified Data.Text as T import Pantry.Internal.AesonExtended ( FromJSONKey (..), FromJSONKeyFunction (..) ) import Stack.Prelude data GhcOptionKey = GOKOldEverything | GOKEverything | GOKLocals | GOKTargets | GOKPackage !PackageName deriving (GhcOptionKey -> GhcOptionKey -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: GhcOptionKey -> GhcOptionKey -> Bool $c/= :: GhcOptionKey -> GhcOptionKey -> Bool == :: GhcOptionKey -> GhcOptionKey -> Bool $c== :: GhcOptionKey -> GhcOptionKey -> Bool Eq, Eq GhcOptionKey GhcOptionKey -> GhcOptionKey -> Bool GhcOptionKey -> GhcOptionKey -> Ordering GhcOptionKey -> GhcOptionKey -> GhcOptionKey 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 :: GhcOptionKey -> GhcOptionKey -> GhcOptionKey $cmin :: GhcOptionKey -> GhcOptionKey -> GhcOptionKey max :: GhcOptionKey -> GhcOptionKey -> GhcOptionKey $cmax :: GhcOptionKey -> GhcOptionKey -> GhcOptionKey >= :: GhcOptionKey -> GhcOptionKey -> Bool $c>= :: GhcOptionKey -> GhcOptionKey -> Bool > :: GhcOptionKey -> GhcOptionKey -> Bool $c> :: GhcOptionKey -> GhcOptionKey -> Bool <= :: GhcOptionKey -> GhcOptionKey -> Bool $c<= :: GhcOptionKey -> GhcOptionKey -> Bool < :: GhcOptionKey -> GhcOptionKey -> Bool $c< :: GhcOptionKey -> GhcOptionKey -> Bool compare :: GhcOptionKey -> GhcOptionKey -> Ordering $ccompare :: GhcOptionKey -> GhcOptionKey -> Ordering Ord) instance FromJSONKey GhcOptionKey where fromJSONKey :: FromJSONKeyFunction GhcOptionKey fromJSONKey = forall a. (Text -> Parser a) -> FromJSONKeyFunction a FromJSONKeyTextParser forall a b. (a -> b) -> a -> b $ \Text t -> case Text t of Text "*" -> forall (f :: * -> *) a. Applicative f => a -> f a pure GhcOptionKey GOKOldEverything Text "$everything" -> forall (f :: * -> *) a. Applicative f => a -> f a pure GhcOptionKey GOKEverything Text "$locals" -> forall (f :: * -> *) a. Applicative f => a -> f a pure GhcOptionKey GOKLocals Text "$targets" -> forall (f :: * -> *) a. Applicative f => a -> f a pure GhcOptionKey GOKTargets Text _ -> case [Char] -> Maybe PackageName parsePackageName forall a b. (a -> b) -> a -> b $ Text -> [Char] T.unpack Text t of Maybe PackageName Nothing -> forall (m :: * -> *) a. MonadFail m => [Char] -> m a fail forall a b. (a -> b) -> a -> b $ [Char] "Invalid package name: " forall a. [a] -> [a] -> [a] ++ forall a. Show a => a -> [Char] show Text t Just PackageName x -> forall (f :: * -> *) a. Applicative f => a -> f a pure forall a b. (a -> b) -> a -> b $ PackageName -> GhcOptionKey GOKPackage PackageName x fromJSONKeyList :: FromJSONKeyFunction [GhcOptionKey] fromJSONKeyList = forall a. (Text -> Parser a) -> FromJSONKeyFunction a FromJSONKeyTextParser forall a b. (a -> b) -> a -> b $ \Text _ -> forall (m :: * -> *) a. MonadFail m => [Char] -> m a fail [Char] "GhcOptionKey.fromJSONKeyList"