module Development.IDE.Graph.Internal.Options where
import Control.Monad.Trans.Reader
import Data.Dynamic
import Development.IDE.Graph.Internal.Types
data ShakeOptions = ShakeOptions {
:: Maybe Dynamic,
ShakeOptions -> Bool
shakeAllowRedefineRules :: Bool,
ShakeOptions -> Bool
shakeTimings :: Bool
}
shakeOptions :: ShakeOptions
shakeOptions :: ShakeOptions
shakeOptions = Maybe Dynamic -> Bool -> Bool -> ShakeOptions
ShakeOptions Maybe Dynamic
forall a. Maybe a
Nothing Bool
False Bool
False
getShakeExtra :: Typeable a => Action (Maybe a)
= do
Dynamic
extra <- ReaderT SAction IO Dynamic -> Action Dynamic
forall a. ReaderT SAction IO a -> Action a
Action (ReaderT SAction IO Dynamic -> Action Dynamic)
-> ReaderT SAction IO Dynamic -> Action Dynamic
forall a b. (a -> b) -> a -> b
$ (SAction -> Dynamic) -> ReaderT SAction IO Dynamic
forall (m :: * -> *) r a. Monad m => (r -> a) -> ReaderT r m a
asks ((SAction -> Dynamic) -> ReaderT SAction IO Dynamic)
-> (SAction -> Dynamic) -> ReaderT SAction IO Dynamic
forall a b. (a -> b) -> a -> b
$ Database -> Dynamic
databaseExtra (Database -> Dynamic)
-> (SAction -> Database) -> SAction -> Dynamic
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SAction -> Database
actionDatabase
Maybe a -> Action (Maybe a)
forall a. a -> Action a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe a -> Action (Maybe a)) -> Maybe a -> Action (Maybe a)
forall a b. (a -> b) -> a -> b
$ Dynamic -> Maybe a
forall a. Typeable a => Dynamic -> Maybe a
fromDynamic Dynamic
extra
getShakeExtraRules :: Typeable a => Rules (Maybe a)
= do
Dynamic
extra <- ReaderT SRules IO Dynamic -> Rules Dynamic
forall a. ReaderT SRules IO a -> Rules a
Rules (ReaderT SRules IO Dynamic -> Rules Dynamic)
-> ReaderT SRules IO Dynamic -> Rules Dynamic
forall a b. (a -> b) -> a -> b
$ (SRules -> Dynamic) -> ReaderT SRules IO Dynamic
forall (m :: * -> *) r a. Monad m => (r -> a) -> ReaderT r m a
asks SRules -> Dynamic
rulesExtra
Maybe a -> Rules (Maybe a)
forall a. a -> Rules a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe a -> Rules (Maybe a)) -> Maybe a -> Rules (Maybe a)
forall a b. (a -> b) -> a -> b
$ Dynamic -> Maybe a
forall a. Typeable a => Dynamic -> Maybe a
fromDynamic Dynamic
extra
newShakeExtra :: Typeable a => a -> Maybe Dynamic
= Dynamic -> Maybe Dynamic
forall a. a -> Maybe a
Just (Dynamic -> Maybe Dynamic) -> (a -> Dynamic) -> a -> Maybe Dynamic
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Dynamic
forall a. Typeable a => a -> Dynamic
toDyn