{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
module Stack.Types.Cache
( FileCache
, BuildFileCache (..)
, FileCacheInfo (..)
, ConfigCache (..)
, CachePkgSrc (..)
, PrecompiledCache (..)
, ConfigCacheType (..)
, Action (..)
) where
import Data.Aeson
( ToJSON (..), FromJSON (..), (.=), (.:), object, withObject
)
import qualified Data.ByteString as S
import qualified Data.Text as T
import Database.Persist.Sql
( PersistField (..), PersistFieldSql (..), PersistValue (..)
, SqlType (..)
)
import Stack.Prelude
import Stack.Types.ConfigureOpts ( ConfigureOpts )
import Stack.Types.GhcPkgId
( GhcPkgId, ghcPkgIdToText, parseGhcPkgId )
data ConfigCacheType
= ConfigCacheTypeConfig
| ConfigCacheTypeFlagLibrary GhcPkgId
| ConfigCacheTypeFlagExecutable PackageIdentifier
deriving (ConfigCacheType -> ConfigCacheType -> Bool
(ConfigCacheType -> ConfigCacheType -> Bool)
-> (ConfigCacheType -> ConfigCacheType -> Bool)
-> Eq ConfigCacheType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConfigCacheType -> ConfigCacheType -> Bool
== :: ConfigCacheType -> ConfigCacheType -> Bool
$c/= :: ConfigCacheType -> ConfigCacheType -> Bool
/= :: ConfigCacheType -> ConfigCacheType -> Bool
Eq, Int -> ConfigCacheType -> ShowS
[ConfigCacheType] -> ShowS
ConfigCacheType -> String
(Int -> ConfigCacheType -> ShowS)
-> (ConfigCacheType -> String)
-> ([ConfigCacheType] -> ShowS)
-> Show ConfigCacheType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConfigCacheType -> ShowS
showsPrec :: Int -> ConfigCacheType -> ShowS
$cshow :: ConfigCacheType -> String
show :: ConfigCacheType -> String
$cshowList :: [ConfigCacheType] -> ShowS
showList :: [ConfigCacheType] -> ShowS
Show)
instance PersistField ConfigCacheType where
toPersistValue :: ConfigCacheType -> PersistValue
toPersistValue ConfigCacheType
ConfigCacheTypeConfig = Text -> PersistValue
PersistText Text
"config"
toPersistValue (ConfigCacheTypeFlagLibrary GhcPkgId
v) =
Text -> PersistValue
PersistText (Text -> PersistValue) -> Text -> PersistValue
forall a b. (a -> b) -> a -> b
$ Text
"lib:" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> GhcPkgId -> Text
ghcPkgIdToText GhcPkgId
v
toPersistValue (ConfigCacheTypeFlagExecutable PackageIdentifier
v) =
Text -> PersistValue
PersistText (Text -> PersistValue) -> Text -> PersistValue
forall a b. (a -> b) -> a -> b
$ Text
"exe:" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (PackageIdentifier -> String
packageIdentifierString PackageIdentifier
v)
fromPersistValue :: PersistValue -> Either Text ConfigCacheType
fromPersistValue (PersistText Text
t) =
Either Text ConfigCacheType
-> Maybe (Either Text ConfigCacheType)
-> Either Text ConfigCacheType
forall a. a -> Maybe a -> a
fromMaybe (Text -> Either Text ConfigCacheType
forall a b. a -> Either a b
Left (Text -> Either Text ConfigCacheType)
-> Text -> Either Text ConfigCacheType
forall a b. (a -> b) -> a -> b
$ Text
"Unexpected ConfigCacheType value: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t) (Maybe (Either Text ConfigCacheType)
-> Either Text ConfigCacheType)
-> Maybe (Either Text ConfigCacheType)
-> Either Text ConfigCacheType
forall a b. (a -> b) -> a -> b
$
Maybe (Either Text ConfigCacheType)
config Maybe (Either Text ConfigCacheType)
-> Maybe (Either Text ConfigCacheType)
-> Maybe (Either Text ConfigCacheType)
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Text -> Either Text ConfigCacheType)
-> Maybe Text -> Maybe (Either Text ConfigCacheType)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Either Text ConfigCacheType
lib (Text -> Text -> Maybe Text
T.stripPrefix Text
"lib:" Text
t) Maybe (Either Text ConfigCacheType)
-> Maybe (Either Text ConfigCacheType)
-> Maybe (Either Text ConfigCacheType)
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(Text -> Either Text ConfigCacheType)
-> Maybe Text -> Maybe (Either Text ConfigCacheType)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Either Text ConfigCacheType
exe (Text -> Text -> Maybe Text
T.stripPrefix Text
"exe:" Text
t)
where
config :: Maybe (Either Text ConfigCacheType)
config
| Text
t Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"config" = Either Text ConfigCacheType -> Maybe (Either Text ConfigCacheType)
forall a. a -> Maybe a
Just (ConfigCacheType -> Either Text ConfigCacheType
forall a b. b -> Either a b
Right ConfigCacheType
ConfigCacheTypeConfig)
| Bool
otherwise = Maybe (Either Text ConfigCacheType)
forall a. Maybe a
Nothing
lib :: Text -> Either Text ConfigCacheType
lib Text
v = do
ghcPkgId <- (SomeException -> Text)
-> Either SomeException GhcPkgId -> Either Text GhcPkgId
forall a1 a2 b. (a1 -> a2) -> Either a1 b -> Either a2 b
mapLeft SomeException -> Text
forall a. Show a => a -> Text
tshow (Text -> Either SomeException GhcPkgId
forall (m :: * -> *). MonadThrow m => Text -> m GhcPkgId
parseGhcPkgId Text
v)
Right $ ConfigCacheTypeFlagLibrary ghcPkgId
exe :: Text -> Either Text ConfigCacheType
exe Text
v = do
pkgId <-
Either Text PackageIdentifier
-> (PackageIdentifier -> Either Text PackageIdentifier)
-> Maybe PackageIdentifier
-> Either Text PackageIdentifier
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Text -> Either Text PackageIdentifier
forall a b. a -> Either a b
Left (Text -> Either Text PackageIdentifier)
-> Text -> Either Text PackageIdentifier
forall a b. (a -> b) -> a -> b
$ Text
"Unexpected ConfigCacheType value: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t) PackageIdentifier -> Either Text PackageIdentifier
forall a b. b -> Either a b
Right (Maybe PackageIdentifier -> Either Text PackageIdentifier)
-> Maybe PackageIdentifier -> Either Text PackageIdentifier
forall a b. (a -> b) -> a -> b
$
String -> Maybe PackageIdentifier
parsePackageIdentifier (Text -> String
T.unpack Text
v)
Right $ ConfigCacheTypeFlagExecutable pkgId
fromPersistValue PersistValue
_ = Text -> Either Text ConfigCacheType
forall a b. a -> Either a b
Left Text
"Unexpected ConfigCacheType type"
instance PersistFieldSql ConfigCacheType where
sqlType :: Proxy ConfigCacheType -> SqlType
sqlType Proxy ConfigCacheType
_ = SqlType
SqlString
data Action
= UpgradeCheck
deriving (Action -> Action -> Bool
(Action -> Action -> Bool)
-> (Action -> Action -> Bool) -> Eq Action
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Action -> Action -> Bool
== :: Action -> Action -> Bool
$c/= :: Action -> Action -> Bool
/= :: Action -> Action -> Bool
Eq, Eq Action
Eq Action =>
(Action -> Action -> Ordering)
-> (Action -> Action -> Bool)
-> (Action -> Action -> Bool)
-> (Action -> Action -> Bool)
-> (Action -> Action -> Bool)
-> (Action -> Action -> Action)
-> (Action -> Action -> Action)
-> Ord Action
Action -> Action -> Bool
Action -> Action -> Ordering
Action -> Action -> Action
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 :: Action -> Action -> Ordering
compare :: Action -> Action -> Ordering
$c< :: Action -> Action -> Bool
< :: Action -> Action -> Bool
$c<= :: Action -> Action -> Bool
<= :: Action -> Action -> Bool
$c> :: Action -> Action -> Bool
> :: Action -> Action -> Bool
$c>= :: Action -> Action -> Bool
>= :: Action -> Action -> Bool
$cmax :: Action -> Action -> Action
max :: Action -> Action -> Action
$cmin :: Action -> Action -> Action
min :: Action -> Action -> Action
Ord, Int -> Action -> ShowS
[Action] -> ShowS
Action -> String
(Int -> Action -> ShowS)
-> (Action -> String) -> ([Action] -> ShowS) -> Show Action
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Action -> ShowS
showsPrec :: Int -> Action -> ShowS
$cshow :: Action -> String
show :: Action -> String
$cshowList :: [Action] -> ShowS
showList :: [Action] -> ShowS
Show)
instance PersistField Action where
toPersistValue :: Action -> PersistValue
toPersistValue Action
UpgradeCheck = Int64 -> PersistValue
PersistInt64 Int64
1
fromPersistValue :: PersistValue -> Either Text Action
fromPersistValue (PersistInt64 Int64
1) = Action -> Either Text Action
forall a b. b -> Either a b
Right Action
UpgradeCheck
fromPersistValue PersistValue
x = Text -> Either Text Action
forall a b. a -> Either a b
Left (Text -> Either Text Action) -> Text -> Either Text Action
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ String
"Invalid Action: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ PersistValue -> String
forall a. Show a => a -> String
show PersistValue
x
instance PersistFieldSql Action where
sqlType :: Proxy Action -> SqlType
sqlType Proxy Action
_ = SqlType
SqlInt64
type FileCache = Map FilePath FileCacheInfo
newtype BuildFileCache = BuildFileCache
{ BuildFileCache -> FileCache
fileCache :: FileCache
}
deriving (BuildFileCache -> BuildFileCache -> Bool
(BuildFileCache -> BuildFileCache -> Bool)
-> (BuildFileCache -> BuildFileCache -> Bool) -> Eq BuildFileCache
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BuildFileCache -> BuildFileCache -> Bool
== :: BuildFileCache -> BuildFileCache -> Bool
$c/= :: BuildFileCache -> BuildFileCache -> Bool
/= :: BuildFileCache -> BuildFileCache -> Bool
Eq, Maybe BuildFileCache
Value -> Parser [BuildFileCache]
Value -> Parser BuildFileCache
(Value -> Parser BuildFileCache)
-> (Value -> Parser [BuildFileCache])
-> Maybe BuildFileCache
-> FromJSON BuildFileCache
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser BuildFileCache
parseJSON :: Value -> Parser BuildFileCache
$cparseJSONList :: Value -> Parser [BuildFileCache]
parseJSONList :: Value -> Parser [BuildFileCache]
$comittedField :: Maybe BuildFileCache
omittedField :: Maybe BuildFileCache
FromJSON, (forall x. BuildFileCache -> Rep BuildFileCache x)
-> (forall x. Rep BuildFileCache x -> BuildFileCache)
-> Generic BuildFileCache
forall x. Rep BuildFileCache x -> BuildFileCache
forall x. BuildFileCache -> Rep BuildFileCache x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BuildFileCache -> Rep BuildFileCache x
from :: forall x. BuildFileCache -> Rep BuildFileCache x
$cto :: forall x. Rep BuildFileCache x -> BuildFileCache
to :: forall x. Rep BuildFileCache x -> BuildFileCache
Generic, Int -> BuildFileCache -> ShowS
[BuildFileCache] -> ShowS
BuildFileCache -> String
(Int -> BuildFileCache -> ShowS)
-> (BuildFileCache -> String)
-> ([BuildFileCache] -> ShowS)
-> Show BuildFileCache
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuildFileCache -> ShowS
showsPrec :: Int -> BuildFileCache -> ShowS
$cshow :: BuildFileCache -> String
show :: BuildFileCache -> String
$cshowList :: [BuildFileCache] -> ShowS
showList :: [BuildFileCache] -> ShowS
Show, [BuildFileCache] -> Value
[BuildFileCache] -> Encoding
BuildFileCache -> Bool
BuildFileCache -> Value
BuildFileCache -> Encoding
(BuildFileCache -> Value)
-> (BuildFileCache -> Encoding)
-> ([BuildFileCache] -> Value)
-> ([BuildFileCache] -> Encoding)
-> (BuildFileCache -> Bool)
-> ToJSON BuildFileCache
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: BuildFileCache -> Value
toJSON :: BuildFileCache -> Value
$ctoEncoding :: BuildFileCache -> Encoding
toEncoding :: BuildFileCache -> Encoding
$ctoJSONList :: [BuildFileCache] -> Value
toJSONList :: [BuildFileCache] -> Value
$ctoEncodingList :: [BuildFileCache] -> Encoding
toEncodingList :: [BuildFileCache] -> Encoding
$comitField :: BuildFileCache -> Bool
omitField :: BuildFileCache -> Bool
ToJSON)
instance NFData BuildFileCache
newtype FileCacheInfo = FileCacheInfo
{ FileCacheInfo -> SHA256
hash :: SHA256
}
deriving (FileCacheInfo -> FileCacheInfo -> Bool
(FileCacheInfo -> FileCacheInfo -> Bool)
-> (FileCacheInfo -> FileCacheInfo -> Bool) -> Eq FileCacheInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FileCacheInfo -> FileCacheInfo -> Bool
== :: FileCacheInfo -> FileCacheInfo -> Bool
$c/= :: FileCacheInfo -> FileCacheInfo -> Bool
/= :: FileCacheInfo -> FileCacheInfo -> Bool
Eq, (forall x. FileCacheInfo -> Rep FileCacheInfo x)
-> (forall x. Rep FileCacheInfo x -> FileCacheInfo)
-> Generic FileCacheInfo
forall x. Rep FileCacheInfo x -> FileCacheInfo
forall x. FileCacheInfo -> Rep FileCacheInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FileCacheInfo -> Rep FileCacheInfo x
from :: forall x. FileCacheInfo -> Rep FileCacheInfo x
$cto :: forall x. Rep FileCacheInfo x -> FileCacheInfo
to :: forall x. Rep FileCacheInfo x -> FileCacheInfo
Generic, Int -> FileCacheInfo -> ShowS
[FileCacheInfo] -> ShowS
FileCacheInfo -> String
(Int -> FileCacheInfo -> ShowS)
-> (FileCacheInfo -> String)
-> ([FileCacheInfo] -> ShowS)
-> Show FileCacheInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FileCacheInfo -> ShowS
showsPrec :: Int -> FileCacheInfo -> ShowS
$cshow :: FileCacheInfo -> String
show :: FileCacheInfo -> String
$cshowList :: [FileCacheInfo] -> ShowS
showList :: [FileCacheInfo] -> ShowS
Show)
instance NFData FileCacheInfo
instance ToJSON FileCacheInfo where
toJSON :: FileCacheInfo -> Value
toJSON FileCacheInfo
fileCacheInfo = [Pair] -> Value
object
[ Key
"hash" Key -> SHA256 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= FileCacheInfo
fileCacheInfo.hash
]
instance FromJSON FileCacheInfo where
parseJSON :: Value -> Parser FileCacheInfo
parseJSON = String
-> (Object -> Parser FileCacheInfo)
-> Value
-> Parser FileCacheInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"FileCacheInfo" ((Object -> Parser FileCacheInfo) -> Value -> Parser FileCacheInfo)
-> (Object -> Parser FileCacheInfo)
-> Value
-> Parser FileCacheInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> SHA256 -> FileCacheInfo
FileCacheInfo
(SHA256 -> FileCacheInfo) -> Parser SHA256 -> Parser FileCacheInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser SHA256
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"hash"
data ConfigCache = ConfigCache
{ ConfigCache -> ConfigureOpts
configureOpts :: !ConfigureOpts
, ConfigCache -> Set GhcPkgId
deps :: !(Set GhcPkgId)
, ConfigCache -> Set ByteString
components :: !(Set S.ByteString)
, ConfigCache -> Bool
buildHaddocks :: !Bool
, ConfigCache -> CachePkgSrc
pkgSrc :: !CachePkgSrc
, ConfigCache -> Text
pathEnvVar :: !Text
}
deriving (Typeable ConfigCache
Typeable ConfigCache =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConfigCache -> c ConfigCache)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConfigCache)
-> (ConfigCache -> Constr)
-> (ConfigCache -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConfigCache))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConfigCache))
-> ((forall b. Data b => b -> b) -> ConfigCache -> ConfigCache)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigCache -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigCache -> r)
-> (forall u. (forall d. Data d => d -> u) -> ConfigCache -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> ConfigCache -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache)
-> Data ConfigCache
ConfigCache -> Constr
ConfigCache -> DataType
(forall b. Data b => b -> b) -> ConfigCache -> ConfigCache
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ConfigCache -> u
forall u. (forall d. Data d => d -> u) -> ConfigCache -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigCache -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigCache -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConfigCache
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConfigCache -> c ConfigCache
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConfigCache)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConfigCache)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConfigCache -> c ConfigCache
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConfigCache -> c ConfigCache
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConfigCache
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConfigCache
$ctoConstr :: ConfigCache -> Constr
toConstr :: ConfigCache -> Constr
$cdataTypeOf :: ConfigCache -> DataType
dataTypeOf :: ConfigCache -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConfigCache)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConfigCache)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConfigCache)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConfigCache)
$cgmapT :: (forall b. Data b => b -> b) -> ConfigCache -> ConfigCache
gmapT :: (forall b. Data b => b -> b) -> ConfigCache -> ConfigCache
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigCache -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigCache -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigCache -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigCache -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ConfigCache -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ConfigCache -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ConfigCache -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ConfigCache -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigCache -> m ConfigCache
Data, ConfigCache -> ConfigCache -> Bool
(ConfigCache -> ConfigCache -> Bool)
-> (ConfigCache -> ConfigCache -> Bool) -> Eq ConfigCache
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConfigCache -> ConfigCache -> Bool
== :: ConfigCache -> ConfigCache -> Bool
$c/= :: ConfigCache -> ConfigCache -> Bool
/= :: ConfigCache -> ConfigCache -> Bool
Eq, (forall x. ConfigCache -> Rep ConfigCache x)
-> (forall x. Rep ConfigCache x -> ConfigCache)
-> Generic ConfigCache
forall x. Rep ConfigCache x -> ConfigCache
forall x. ConfigCache -> Rep ConfigCache x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConfigCache -> Rep ConfigCache x
from :: forall x. ConfigCache -> Rep ConfigCache x
$cto :: forall x. Rep ConfigCache x -> ConfigCache
to :: forall x. Rep ConfigCache x -> ConfigCache
Generic, Int -> ConfigCache -> ShowS
[ConfigCache] -> ShowS
ConfigCache -> String
(Int -> ConfigCache -> ShowS)
-> (ConfigCache -> String)
-> ([ConfigCache] -> ShowS)
-> Show ConfigCache
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConfigCache -> ShowS
showsPrec :: Int -> ConfigCache -> ShowS
$cshow :: ConfigCache -> String
show :: ConfigCache -> String
$cshowList :: [ConfigCache] -> ShowS
showList :: [ConfigCache] -> ShowS
Show)
instance NFData ConfigCache
data CachePkgSrc
= CacheSrcUpstream
| CacheSrcLocal FilePath
deriving (Typeable CachePkgSrc
Typeable CachePkgSrc =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CachePkgSrc -> c CachePkgSrc)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CachePkgSrc)
-> (CachePkgSrc -> Constr)
-> (CachePkgSrc -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CachePkgSrc))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CachePkgSrc))
-> ((forall b. Data b => b -> b) -> CachePkgSrc -> CachePkgSrc)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CachePkgSrc -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CachePkgSrc -> r)
-> (forall u. (forall d. Data d => d -> u) -> CachePkgSrc -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> CachePkgSrc -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc)
-> Data CachePkgSrc
CachePkgSrc -> Constr
CachePkgSrc -> DataType
(forall b. Data b => b -> b) -> CachePkgSrc -> CachePkgSrc
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> CachePkgSrc -> u
forall u. (forall d. Data d => d -> u) -> CachePkgSrc -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CachePkgSrc -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CachePkgSrc -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CachePkgSrc
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CachePkgSrc -> c CachePkgSrc
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CachePkgSrc)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CachePkgSrc)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CachePkgSrc -> c CachePkgSrc
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CachePkgSrc -> c CachePkgSrc
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CachePkgSrc
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CachePkgSrc
$ctoConstr :: CachePkgSrc -> Constr
toConstr :: CachePkgSrc -> Constr
$cdataTypeOf :: CachePkgSrc -> DataType
dataTypeOf :: CachePkgSrc -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CachePkgSrc)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CachePkgSrc)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CachePkgSrc)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CachePkgSrc)
$cgmapT :: (forall b. Data b => b -> b) -> CachePkgSrc -> CachePkgSrc
gmapT :: (forall b. Data b => b -> b) -> CachePkgSrc -> CachePkgSrc
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CachePkgSrc -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CachePkgSrc -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CachePkgSrc -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CachePkgSrc -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CachePkgSrc -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> CachePkgSrc -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CachePkgSrc -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CachePkgSrc -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CachePkgSrc -> m CachePkgSrc
Data, CachePkgSrc -> CachePkgSrc -> Bool
(CachePkgSrc -> CachePkgSrc -> Bool)
-> (CachePkgSrc -> CachePkgSrc -> Bool) -> Eq CachePkgSrc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CachePkgSrc -> CachePkgSrc -> Bool
== :: CachePkgSrc -> CachePkgSrc -> Bool
$c/= :: CachePkgSrc -> CachePkgSrc -> Bool
/= :: CachePkgSrc -> CachePkgSrc -> Bool
Eq, (forall x. CachePkgSrc -> Rep CachePkgSrc x)
-> (forall x. Rep CachePkgSrc x -> CachePkgSrc)
-> Generic CachePkgSrc
forall x. Rep CachePkgSrc x -> CachePkgSrc
forall x. CachePkgSrc -> Rep CachePkgSrc x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CachePkgSrc -> Rep CachePkgSrc x
from :: forall x. CachePkgSrc -> Rep CachePkgSrc x
$cto :: forall x. Rep CachePkgSrc x -> CachePkgSrc
to :: forall x. Rep CachePkgSrc x -> CachePkgSrc
Generic, ReadPrec [CachePkgSrc]
ReadPrec CachePkgSrc
Int -> ReadS CachePkgSrc
ReadS [CachePkgSrc]
(Int -> ReadS CachePkgSrc)
-> ReadS [CachePkgSrc]
-> ReadPrec CachePkgSrc
-> ReadPrec [CachePkgSrc]
-> Read CachePkgSrc
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS CachePkgSrc
readsPrec :: Int -> ReadS CachePkgSrc
$creadList :: ReadS [CachePkgSrc]
readList :: ReadS [CachePkgSrc]
$creadPrec :: ReadPrec CachePkgSrc
readPrec :: ReadPrec CachePkgSrc
$creadListPrec :: ReadPrec [CachePkgSrc]
readListPrec :: ReadPrec [CachePkgSrc]
Read, Int -> CachePkgSrc -> ShowS
[CachePkgSrc] -> ShowS
CachePkgSrc -> String
(Int -> CachePkgSrc -> ShowS)
-> (CachePkgSrc -> String)
-> ([CachePkgSrc] -> ShowS)
-> Show CachePkgSrc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CachePkgSrc -> ShowS
showsPrec :: Int -> CachePkgSrc -> ShowS
$cshow :: CachePkgSrc -> String
show :: CachePkgSrc -> String
$cshowList :: [CachePkgSrc] -> ShowS
showList :: [CachePkgSrc] -> ShowS
Show)
instance NFData CachePkgSrc
instance PersistField CachePkgSrc where
toPersistValue :: CachePkgSrc -> PersistValue
toPersistValue CachePkgSrc
CacheSrcUpstream = Text -> PersistValue
PersistText Text
"upstream"
toPersistValue (CacheSrcLocal String
fp) = Text -> PersistValue
PersistText (Text
"local:" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack String
fp)
fromPersistValue :: PersistValue -> Either Text CachePkgSrc
fromPersistValue (PersistText Text
t) =
if Text
t Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"upstream"
then CachePkgSrc -> Either Text CachePkgSrc
forall a b. b -> Either a b
Right CachePkgSrc
CacheSrcUpstream
else case Text -> Text -> Maybe Text
T.stripPrefix Text
"local:" Text
t of
Just Text
fp -> CachePkgSrc -> Either Text CachePkgSrc
forall a b. b -> Either a b
Right (CachePkgSrc -> Either Text CachePkgSrc)
-> CachePkgSrc -> Either Text CachePkgSrc
forall a b. (a -> b) -> a -> b
$ String -> CachePkgSrc
CacheSrcLocal (Text -> String
T.unpack Text
fp)
Maybe Text
Nothing -> Text -> Either Text CachePkgSrc
forall a b. a -> Either a b
Left (Text -> Either Text CachePkgSrc)
-> Text -> Either Text CachePkgSrc
forall a b. (a -> b) -> a -> b
$ Text
"Unexpected CachePkgSrc value: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t
fromPersistValue PersistValue
_ = Text -> Either Text CachePkgSrc
forall a b. a -> Either a b
Left Text
"Unexpected CachePkgSrc type"
instance PersistFieldSql CachePkgSrc where
sqlType :: Proxy CachePkgSrc -> SqlType
sqlType Proxy CachePkgSrc
_ = SqlType
SqlString
data PrecompiledCache base = PrecompiledCache
{ forall base. PrecompiledCache base -> Maybe (Path base File)
library :: !(Maybe (Path base File))
, forall base. PrecompiledCache base -> [Path base File]
subLibs :: ![Path base File]
, forall base. PrecompiledCache base -> [Path base File]
exes :: ![Path base File]
}
deriving (PrecompiledCache base -> PrecompiledCache base -> Bool
(PrecompiledCache base -> PrecompiledCache base -> Bool)
-> (PrecompiledCache base -> PrecompiledCache base -> Bool)
-> Eq (PrecompiledCache base)
forall base. PrecompiledCache base -> PrecompiledCache base -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall base. PrecompiledCache base -> PrecompiledCache base -> Bool
== :: PrecompiledCache base -> PrecompiledCache base -> Bool
$c/= :: forall base. PrecompiledCache base -> PrecompiledCache base -> Bool
/= :: PrecompiledCache base -> PrecompiledCache base -> Bool
Eq, (forall x. PrecompiledCache base -> Rep (PrecompiledCache base) x)
-> (forall x.
Rep (PrecompiledCache base) x -> PrecompiledCache base)
-> Generic (PrecompiledCache base)
forall x. Rep (PrecompiledCache base) x -> PrecompiledCache base
forall x. PrecompiledCache base -> Rep (PrecompiledCache base) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall base x.
Rep (PrecompiledCache base) x -> PrecompiledCache base
forall base x.
PrecompiledCache base -> Rep (PrecompiledCache base) x
$cfrom :: forall base x.
PrecompiledCache base -> Rep (PrecompiledCache base) x
from :: forall x. PrecompiledCache base -> Rep (PrecompiledCache base) x
$cto :: forall base x.
Rep (PrecompiledCache base) x -> PrecompiledCache base
to :: forall x. Rep (PrecompiledCache base) x -> PrecompiledCache base
Generic, Int -> PrecompiledCache base -> ShowS
[PrecompiledCache base] -> ShowS
PrecompiledCache base -> String
(Int -> PrecompiledCache base -> ShowS)
-> (PrecompiledCache base -> String)
-> ([PrecompiledCache base] -> ShowS)
-> Show (PrecompiledCache base)
forall base. Int -> PrecompiledCache base -> ShowS
forall base. [PrecompiledCache base] -> ShowS
forall base. PrecompiledCache base -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall base. Int -> PrecompiledCache base -> ShowS
showsPrec :: Int -> PrecompiledCache base -> ShowS
$cshow :: forall base. PrecompiledCache base -> String
show :: PrecompiledCache base -> String
$cshowList :: forall base. [PrecompiledCache base] -> ShowS
showList :: [PrecompiledCache base] -> ShowS
Show)
instance NFData (PrecompiledCache Abs)
instance NFData (PrecompiledCache Rel)