module Development.IDE.Graph.Internal.Options where

import           Control.Monad.Trans.Reader
import           Data.Dynamic
import           Development.IDE.Graph.Internal.Types

data ShakeOptions = ShakeOptions {
    ShakeOptions -> Maybe Dynamic
shakeExtra              :: Maybe Dynamic,
    ShakeOptions -> Bool
shakeAllowRedefineRules :: Bool,
    ShakeOptions -> Bool
shakeTimings            :: Bool
    }

shakeOptions :: ShakeOptions
shakeOptions :: ShakeOptions
shakeOptions = Maybe Dynamic -> Bool -> Bool -> ShakeOptions
ShakeOptions forall a. Maybe a
Nothing Bool
False Bool
False

getShakeExtra :: Typeable a => Action (Maybe a)
getShakeExtra :: forall a. Typeable a => Action (Maybe a)
getShakeExtra = do
    Dynamic
extra <- forall a. ReaderT SAction IO a -> Action a
Action forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) r a. Monad m => (r -> a) -> ReaderT r m a
asks forall a b. (a -> b) -> a -> b
$ Database -> Dynamic
databaseExtra forall b c a. (b -> c) -> (a -> b) -> a -> c
. SAction -> Database
actionDatabase
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. Typeable a => Dynamic -> Maybe a
fromDynamic Dynamic
extra

getShakeExtraRules :: Typeable a => Rules (Maybe a)
getShakeExtraRules :: forall a. Typeable a => Rules (Maybe a)
getShakeExtraRules = do
    Dynamic
extra <- forall a. ReaderT SRules IO a -> Rules a
Rules forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) r a. Monad m => (r -> a) -> ReaderT r m a
asks SRules -> Dynamic
rulesExtra
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. Typeable a => Dynamic -> Maybe a
fromDynamic Dynamic
extra

newShakeExtra :: Typeable a => a -> Maybe Dynamic
newShakeExtra :: forall a. Typeable a => a -> Maybe Dynamic
newShakeExtra = forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Typeable a => a -> Dynamic
toDyn