{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables, DeriveDataTypeable, ViewPatterns #-}
{-# LANGUAGE ExistentialQuantification, DeriveFunctor, RecordWildCards, FlexibleInstances #-}
module Development.Shake.Internal.Core.Types(
BuiltinRun, BuiltinLint, BuiltinIdentity,
RunMode(..), RunResult(..), RunChanged(..),
UserRule(..), UserRuleVersioned(..), userRuleSize,
BuiltinRule(..), Global(..), Local(..), Action(..), runAction, addDiscount,
newLocal, localClearMutable, localMergeMutable,
Stack, Step(..), Result(..), Database, DatabasePoly(..), Depends(..), Status(..), Trace(..), BS_Store,
getResult, exceptionStack, statusType, addStack, addCallStack,
incStep, newTrace, nubDepends, emptyStack, topStack, showTopStack,
stepKey, StepKey(..),
rootKey, Root(..)
) where
import Control.Monad.IO.Class
import Control.DeepSeq
import Foreign.Storable
import Data.Word
import Data.Typeable
import General.Binary
import Data.Maybe
import Data.List
import Control.Exception
import General.Extra
import Development.Shake.Internal.Core.Database
import Development.Shake.Internal.History.Shared
import Development.Shake.Internal.History.Cloud
import Development.Shake.Internal.History.Types
import Development.Shake.Internal.Errors
import qualified General.TypeMap as TMap
import Data.IORef
import qualified Data.ByteString.Char8 as BS
import Numeric.Extra
import System.Time.Extra
import General.Intern(Id)
import qualified Data.HashSet as Set
import qualified Data.HashMap.Strict as Map
import Data.Tuple.Extra
import General.Pool
import Development.Shake.Internal.Core.Monad
import Development.Shake.Internal.Value
import Development.Shake.Internal.Options
import Development.Shake.Classes
import Data.Semigroup
import General.Cleanup
import Control.Monad.Fail
import Prelude
newtype Action a = Action {Action a -> RAW ([String], [Key]) [Value] Global Local a
fromAction :: RAW ([String],[Key]) [Value] Global Local a}
deriving (a -> Action b -> Action a
(a -> b) -> Action a -> Action b
(forall a b. (a -> b) -> Action a -> Action b)
-> (forall a b. a -> Action b -> Action a) -> Functor Action
forall a b. a -> Action b -> Action a
forall a b. (a -> b) -> Action a -> Action b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Action b -> Action a
$c<$ :: forall a b. a -> Action b -> Action a
fmap :: (a -> b) -> Action a -> Action b
$cfmap :: forall a b. (a -> b) -> Action a -> Action b
Functor, Functor Action
a -> Action a
Functor Action =>
(forall a. a -> Action a)
-> (forall a b. Action (a -> b) -> Action a -> Action b)
-> (forall a b c.
(a -> b -> c) -> Action a -> Action b -> Action c)
-> (forall a b. Action a -> Action b -> Action b)
-> (forall a b. Action a -> Action b -> Action a)
-> Applicative Action
Action a -> Action b -> Action b
Action a -> Action b -> Action a
Action (a -> b) -> Action a -> Action b
(a -> b -> c) -> Action a -> Action b -> Action c
forall a. a -> Action a
forall a b. Action a -> Action b -> Action a
forall a b. Action a -> Action b -> Action b
forall a b. Action (a -> b) -> Action a -> Action b
forall a b c. (a -> b -> c) -> Action a -> Action b -> Action c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: Action a -> Action b -> Action a
$c<* :: forall a b. Action a -> Action b -> Action a
*> :: Action a -> Action b -> Action b
$c*> :: forall a b. Action a -> Action b -> Action b
liftA2 :: (a -> b -> c) -> Action a -> Action b -> Action c
$cliftA2 :: forall a b c. (a -> b -> c) -> Action a -> Action b -> Action c
<*> :: Action (a -> b) -> Action a -> Action b
$c<*> :: forall a b. Action (a -> b) -> Action a -> Action b
pure :: a -> Action a
$cpure :: forall a. a -> Action a
$cp1Applicative :: Functor Action
Applicative, Applicative Action
a -> Action a
Applicative Action =>
(forall a b. Action a -> (a -> Action b) -> Action b)
-> (forall a b. Action a -> Action b -> Action b)
-> (forall a. a -> Action a)
-> Monad Action
Action a -> (a -> Action b) -> Action b
Action a -> Action b -> Action b
forall a. a -> Action a
forall a b. Action a -> Action b -> Action b
forall a b. Action a -> (a -> Action b) -> Action b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> Action a
$creturn :: forall a. a -> Action a
>> :: Action a -> Action b -> Action b
$c>> :: forall a b. Action a -> Action b -> Action b
>>= :: Action a -> (a -> Action b) -> Action b
$c>>= :: forall a b. Action a -> (a -> Action b) -> Action b
$cp1Monad :: Applicative Action
Monad, Monad Action
Monad Action => (forall a. IO a -> Action a) -> MonadIO Action
IO a -> Action a
forall a. IO a -> Action a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> Action a
$cliftIO :: forall a. IO a -> Action a
$cp1MonadIO :: Monad Action
MonadIO, Typeable, b -> Action a -> Action a
NonEmpty (Action a) -> Action a
Action a -> Action a -> Action a
(Action a -> Action a -> Action a)
-> (NonEmpty (Action a) -> Action a)
-> (forall b. Integral b => b -> Action a -> Action a)
-> Semigroup (Action a)
forall b. Integral b => b -> Action a -> Action a
forall a. Semigroup a => NonEmpty (Action a) -> Action a
forall a. Semigroup a => Action a -> Action a -> Action a
forall a b. (Semigroup a, Integral b) => b -> Action a -> Action a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> Action a -> Action a
$cstimes :: forall a b. (Semigroup a, Integral b) => b -> Action a -> Action a
sconcat :: NonEmpty (Action a) -> Action a
$csconcat :: forall a. Semigroup a => NonEmpty (Action a) -> Action a
<> :: Action a -> Action a -> Action a
$c<> :: forall a. Semigroup a => Action a -> Action a -> Action a
Semigroup, Semigroup (Action a)
Action a
Semigroup (Action a) =>
Action a
-> (Action a -> Action a -> Action a)
-> ([Action a] -> Action a)
-> Monoid (Action a)
[Action a] -> Action a
Action a -> Action a -> Action a
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall a. Monoid a => Semigroup (Action a)
forall a. Monoid a => Action a
forall a. Monoid a => [Action a] -> Action a
forall a. Monoid a => Action a -> Action a -> Action a
mconcat :: [Action a] -> Action a
$cmconcat :: forall a. Monoid a => [Action a] -> Action a
mappend :: Action a -> Action a -> Action a
$cmappend :: forall a. Monoid a => Action a -> Action a -> Action a
mempty :: Action a
$cmempty :: forall a. Monoid a => Action a
$cp1Monoid :: forall a. Monoid a => Semigroup (Action a)
Monoid, Monad Action
Monad Action => (forall a. String -> Action a) -> MonadFail Action
String -> Action a
forall a. String -> Action a
forall (m :: * -> *).
Monad m =>
(forall a. String -> m a) -> MonadFail m
fail :: String -> Action a
$cfail :: forall a. String -> Action a
$cp1MonadFail :: Monad Action
MonadFail)
runAction :: Global -> Local -> Action a -> Capture (Either SomeException a)
runAction :: Global -> Local -> Action a -> Capture (Either SomeException a)
runAction g :: Global
g l :: Local
l (Action x :: RAW ([String], [Key]) [Value] Global Local a
x) = ([([String], [Key])]
-> RAW ([String], [Key]) [Value] Global Local [[Value]])
-> Global
-> Local
-> RAW ([String], [Key]) [Value] Global Local a
-> Capture (Either SomeException a)
forall k v ro rw a.
([k] -> RAW k v ro rw [v])
-> ro -> rw -> RAW k v ro rw a -> Capture (Either SomeException a)
runRAW (Action [[Value]]
-> RAW ([String], [Key]) [Value] Global Local [[Value]]
forall a. Action a -> RAW ([String], [Key]) [Value] Global Local a
fromAction (Action [[Value]]
-> RAW ([String], [Key]) [Value] Global Local [[Value]])
-> ([([String], [Key])] -> Action [[Value]])
-> [([String], [Key])]
-> RAW ([String], [Key]) [Value] Global Local [[Value]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [([String], [Key])] -> Action [[Value]]
build) Global
g Local
l RAW ([String], [Key]) [Value] Global Local a
x
where
build :: [([String], [Key])] -> Action [[Value]]
build :: [([String], [Key])] -> Action [[Value]]
build [] = [[Value]] -> Action [[Value]]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
build ks :: [([String], [Key])]
ks@((callstack :: [String]
callstack,_):_) = do
let kss :: [[Key]]
kss = (([String], [Key]) -> [Key]) -> [([String], [Key])] -> [[Key]]
forall a b. (a -> b) -> [a] -> [b]
map ([String], [Key]) -> [Key]
forall a b. (a, b) -> b
snd [([String], [Key])]
ks
[[Key]] -> [Value] -> [[Value]]
forall a b. [[a]] -> [b] -> [[b]]
unconcat [[Key]]
kss ([Value] -> [[Value]]) -> Action [Value] -> Action [[Value]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Global -> [String] -> [Key] -> Action [Value]
globalBuild Global
g [String]
callstack ([[Key]] -> [Key]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Key]]
kss)
data RunMode
= RunDependenciesSame
| RunDependenciesChanged
deriving (RunMode -> RunMode -> Bool
(RunMode -> RunMode -> Bool)
-> (RunMode -> RunMode -> Bool) -> Eq RunMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RunMode -> RunMode -> Bool
$c/= :: RunMode -> RunMode -> Bool
== :: RunMode -> RunMode -> Bool
$c== :: RunMode -> RunMode -> Bool
Eq,Int -> RunMode -> ShowS
[RunMode] -> ShowS
RunMode -> String
(Int -> RunMode -> ShowS)
-> (RunMode -> String) -> ([RunMode] -> ShowS) -> Show RunMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RunMode] -> ShowS
$cshowList :: [RunMode] -> ShowS
show :: RunMode -> String
$cshow :: RunMode -> String
showsPrec :: Int -> RunMode -> ShowS
$cshowsPrec :: Int -> RunMode -> ShowS
Show)
instance NFData RunMode where rnf :: RunMode -> ()
rnf x :: RunMode
x = RunMode
x RunMode -> () -> ()
forall a b. a -> b -> b
`seq` ()
data RunChanged
= ChangedNothing
| ChangedStore
| ChangedRecomputeSame
| ChangedRecomputeDiff
deriving (RunChanged -> RunChanged -> Bool
(RunChanged -> RunChanged -> Bool)
-> (RunChanged -> RunChanged -> Bool) -> Eq RunChanged
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RunChanged -> RunChanged -> Bool
$c/= :: RunChanged -> RunChanged -> Bool
== :: RunChanged -> RunChanged -> Bool
$c== :: RunChanged -> RunChanged -> Bool
Eq,Int -> RunChanged -> ShowS
[RunChanged] -> ShowS
RunChanged -> String
(Int -> RunChanged -> ShowS)
-> (RunChanged -> String)
-> ([RunChanged] -> ShowS)
-> Show RunChanged
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RunChanged] -> ShowS
$cshowList :: [RunChanged] -> ShowS
show :: RunChanged -> String
$cshow :: RunChanged -> String
showsPrec :: Int -> RunChanged -> ShowS
$cshowsPrec :: Int -> RunChanged -> ShowS
Show)
instance NFData RunChanged where rnf :: RunChanged -> ()
rnf x :: RunChanged
x = RunChanged
x RunChanged -> () -> ()
forall a b. a -> b -> b
`seq` ()
data RunResult value = RunResult
{RunResult value -> RunChanged
runChanged :: RunChanged
,RunResult value -> ByteString
runStore :: BS.ByteString
,RunResult value -> value
runValue :: value
} deriving a -> RunResult b -> RunResult a
(a -> b) -> RunResult a -> RunResult b
(forall a b. (a -> b) -> RunResult a -> RunResult b)
-> (forall a b. a -> RunResult b -> RunResult a)
-> Functor RunResult
forall a b. a -> RunResult b -> RunResult a
forall a b. (a -> b) -> RunResult a -> RunResult b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> RunResult b -> RunResult a
$c<$ :: forall a b. a -> RunResult b -> RunResult a
fmap :: (a -> b) -> RunResult a -> RunResult b
$cfmap :: forall a b. (a -> b) -> RunResult a -> RunResult b
Functor
instance NFData value => NFData (RunResult value) where
rnf :: RunResult value -> ()
rnf (RunResult x1 :: RunChanged
x1 x2 :: ByteString
x2 x3 :: value
x3) = RunChanged -> ()
forall a. NFData a => a -> ()
rnf RunChanged
x1 () -> () -> ()
forall a b. a -> b -> b
`seq` ByteString
x2 ByteString -> () -> ()
forall a b. a -> b -> b
`seq` value -> ()
forall a. NFData a => a -> ()
rnf value
x3
newtype Step = Step Word32 deriving (Step -> Step -> Bool
(Step -> Step -> Bool) -> (Step -> Step -> Bool) -> Eq Step
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Step -> Step -> Bool
$c/= :: Step -> Step -> Bool
== :: Step -> Step -> Bool
$c== :: Step -> Step -> Bool
Eq,Eq Step
Eq Step =>
(Step -> Step -> Ordering)
-> (Step -> Step -> Bool)
-> (Step -> Step -> Bool)
-> (Step -> Step -> Bool)
-> (Step -> Step -> Bool)
-> (Step -> Step -> Step)
-> (Step -> Step -> Step)
-> Ord Step
Step -> Step -> Bool
Step -> Step -> Ordering
Step -> Step -> Step
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 :: Step -> Step -> Step
$cmin :: Step -> Step -> Step
max :: Step -> Step -> Step
$cmax :: Step -> Step -> Step
>= :: Step -> Step -> Bool
$c>= :: Step -> Step -> Bool
> :: Step -> Step -> Bool
$c> :: Step -> Step -> Bool
<= :: Step -> Step -> Bool
$c<= :: Step -> Step -> Bool
< :: Step -> Step -> Bool
$c< :: Step -> Step -> Bool
compare :: Step -> Step -> Ordering
$ccompare :: Step -> Step -> Ordering
$cp1Ord :: Eq Step
Ord,Int -> Step -> ShowS
[Step] -> ShowS
Step -> String
(Int -> Step -> ShowS)
-> (Step -> String) -> ([Step] -> ShowS) -> Show Step
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Step] -> ShowS
$cshowList :: [Step] -> ShowS
show :: Step -> String
$cshow :: Step -> String
showsPrec :: Int -> Step -> ShowS
$cshowsPrec :: Int -> Step -> ShowS
Show,Ptr b -> Int -> IO Step
Ptr b -> Int -> Step -> IO ()
Ptr Step -> IO Step
Ptr Step -> Int -> IO Step
Ptr Step -> Int -> Step -> IO ()
Ptr Step -> Step -> IO ()
Step -> Int
(Step -> Int)
-> (Step -> Int)
-> (Ptr Step -> Int -> IO Step)
-> (Ptr Step -> Int -> Step -> IO ())
-> (forall b. Ptr b -> Int -> IO Step)
-> (forall b. Ptr b -> Int -> Step -> IO ())
-> (Ptr Step -> IO Step)
-> (Ptr Step -> Step -> IO ())
-> Storable Step
forall b. Ptr b -> Int -> IO Step
forall b. Ptr b -> Int -> Step -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr Step -> Step -> IO ()
$cpoke :: Ptr Step -> Step -> IO ()
peek :: Ptr Step -> IO Step
$cpeek :: Ptr Step -> IO Step
pokeByteOff :: Ptr b -> Int -> Step -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> Step -> IO ()
peekByteOff :: Ptr b -> Int -> IO Step
$cpeekByteOff :: forall b. Ptr b -> Int -> IO Step
pokeElemOff :: Ptr Step -> Int -> Step -> IO ()
$cpokeElemOff :: Ptr Step -> Int -> Step -> IO ()
peekElemOff :: Ptr Step -> Int -> IO Step
$cpeekElemOff :: Ptr Step -> Int -> IO Step
alignment :: Step -> Int
$calignment :: Step -> Int
sizeOf :: Step -> Int
$csizeOf :: Step -> Int
Storable,ByteString -> Step
Step -> Builder
(Step -> Builder) -> (ByteString -> Step) -> BinaryEx Step
forall a. (a -> Builder) -> (ByteString -> a) -> BinaryEx a
getEx :: ByteString -> Step
$cgetEx :: ByteString -> Step
putEx :: Step -> Builder
$cputEx :: Step -> Builder
BinaryEx,Step -> ()
(Step -> ()) -> NFData Step
forall a. (a -> ()) -> NFData a
rnf :: Step -> ()
$crnf :: Step -> ()
NFData,Int -> Step -> Int
Step -> Int
(Int -> Step -> Int) -> (Step -> Int) -> Hashable Step
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: Step -> Int
$chash :: Step -> Int
hashWithSalt :: Int -> Step -> Int
$chashWithSalt :: Int -> Step -> Int
Hashable,Typeable)
incStep :: Step -> Step
incStep (Step i :: Word32
i) = Word32 -> Step
Step (Word32 -> Step) -> Word32 -> Step
forall a b. (a -> b) -> a -> b
$ Word32
i Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
+ 1
newtype StepKey = StepKey ()
deriving (Int -> StepKey -> ShowS
[StepKey] -> ShowS
StepKey -> String
(Int -> StepKey -> ShowS)
-> (StepKey -> String) -> ([StepKey] -> ShowS) -> Show StepKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StepKey] -> ShowS
$cshowList :: [StepKey] -> ShowS
show :: StepKey -> String
$cshow :: StepKey -> String
showsPrec :: Int -> StepKey -> ShowS
$cshowsPrec :: Int -> StepKey -> ShowS
Show,StepKey -> StepKey -> Bool
(StepKey -> StepKey -> Bool)
-> (StepKey -> StepKey -> Bool) -> Eq StepKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StepKey -> StepKey -> Bool
$c/= :: StepKey -> StepKey -> Bool
== :: StepKey -> StepKey -> Bool
$c== :: StepKey -> StepKey -> Bool
Eq,Typeable,Int -> StepKey -> Int
StepKey -> Int
(Int -> StepKey -> Int) -> (StepKey -> Int) -> Hashable StepKey
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: StepKey -> Int
$chash :: StepKey -> Int
hashWithSalt :: Int -> StepKey -> Int
$chashWithSalt :: Int -> StepKey -> Int
Hashable,Get StepKey
[StepKey] -> Put
StepKey -> Put
(StepKey -> Put)
-> Get StepKey -> ([StepKey] -> Put) -> Binary StepKey
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
putList :: [StepKey] -> Put
$cputList :: [StepKey] -> Put
get :: Get StepKey
$cget :: Get StepKey
put :: StepKey -> Put
$cput :: StepKey -> Put
Binary,ByteString -> StepKey
StepKey -> Builder
(StepKey -> Builder) -> (ByteString -> StepKey) -> BinaryEx StepKey
forall a. (a -> Builder) -> (ByteString -> a) -> BinaryEx a
getEx :: ByteString -> StepKey
$cgetEx :: ByteString -> StepKey
putEx :: StepKey -> Builder
$cputEx :: StepKey -> Builder
BinaryEx,StepKey -> ()
(StepKey -> ()) -> NFData StepKey
forall a. (a -> ()) -> NFData a
rnf :: StepKey -> ()
$crnf :: StepKey -> ()
NFData)
stepKey :: Key
stepKey :: Key
stepKey = StepKey -> Key
forall a. ShakeValue a => a -> Key
newKey (StepKey -> Key) -> StepKey -> Key
forall a b. (a -> b) -> a -> b
$ () -> StepKey
StepKey ()
newtype Root = Root () deriving (Root -> Root -> Bool
(Root -> Root -> Bool) -> (Root -> Root -> Bool) -> Eq Root
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Root -> Root -> Bool
$c/= :: Root -> Root -> Bool
== :: Root -> Root -> Bool
$c== :: Root -> Root -> Bool
Eq,Typeable,Int -> Root -> Int
Root -> Int
(Int -> Root -> Int) -> (Root -> Int) -> Hashable Root
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: Root -> Int
$chash :: Root -> Int
hashWithSalt :: Int -> Root -> Int
$chashWithSalt :: Int -> Root -> Int
Hashable,Get Root
[Root] -> Put
Root -> Put
(Root -> Put) -> Get Root -> ([Root] -> Put) -> Binary Root
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
putList :: [Root] -> Put
$cputList :: [Root] -> Put
get :: Get Root
$cget :: Get Root
put :: Root -> Put
$cput :: Root -> Put
Binary,ByteString -> Root
Root -> Builder
(Root -> Builder) -> (ByteString -> Root) -> BinaryEx Root
forall a. (a -> Builder) -> (ByteString -> a) -> BinaryEx a
getEx :: ByteString -> Root
$cgetEx :: ByteString -> Root
putEx :: Root -> Builder
$cputEx :: Root -> Builder
BinaryEx,Root -> ()
(Root -> ()) -> NFData Root
forall a. (a -> ()) -> NFData a
rnf :: Root -> ()
$crnf :: Root -> ()
NFData)
instance Show Root where
show :: Root -> String
show (Root ()) = "Root"
rootKey :: Key
rootKey :: Key
rootKey = Root -> Key
forall a. ShakeValue a => a -> Key
newKey (Root -> Key) -> Root -> Key
forall a b. (a -> b) -> a -> b
$ () -> Root
Root ()
data Stack = Stack (Maybe Key) [Either Key [String]] !(Set.HashSet Id) deriving Int -> Stack -> ShowS
[Stack] -> ShowS
Stack -> String
(Int -> Stack -> ShowS)
-> (Stack -> String) -> ([Stack] -> ShowS) -> Show Stack
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Stack] -> ShowS
$cshowList :: [Stack] -> ShowS
show :: Stack -> String
$cshow :: Stack -> String
showsPrec :: Int -> Stack -> ShowS
$cshowsPrec :: Int -> Stack -> ShowS
Show
exceptionStack :: Stack -> SomeException -> ShakeException
exceptionStack :: Stack -> SomeException -> ShakeException
exceptionStack stack :: Stack
stack@(Stack _ xs1 :: [Either Key [String]]
xs1 _) (SomeException -> ([String], SomeException)
callStackFromException -> (xs2 :: [String]
xs2, e :: SomeException
e)) =
String -> [String] -> SomeException -> ShakeException
ShakeException
(Stack -> String
showTopStack Stack
stack)
([String]
xs [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ["* Raised the exception:" | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [String] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
xs])
SomeException
e
where
xs :: [String]
xs = (Either Key [String] -> [String])
-> [Either Key [String]] -> [String]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Either Key [String] -> [String]
forall a. Show a => Either a [String] -> [String]
f ([Either Key [String]] -> [String])
-> [Either Key [String]] -> [String]
forall a b. (a -> b) -> a -> b
$ [Either Key [String]] -> [Either Key [String]]
forall a. [a] -> [a]
reverse [Either Key [String]]
xs1 [Either Key [String]]
-> [Either Key [String]] -> [Either Key [String]]
forall a. [a] -> [a] -> [a]
++ [[String] -> Either Key [String]
forall a b. b -> Either a b
Right [String]
xs2]
f :: Either a [String] -> [String]
f (Left x :: a
x) = ["* Depends on: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
x]
f (Right x :: [String]
x) = ShowS -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (" at " String -> ShowS
forall a. [a] -> [a] -> [a]
++) [String]
x
showTopStack :: Stack -> String
showTopStack :: Stack -> String
showTopStack = String -> (Key -> String) -> Maybe Key -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe "<unknown>" Key -> String
forall a. Show a => a -> String
show (Maybe Key -> String) -> (Stack -> Maybe Key) -> Stack -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Stack -> Maybe Key
topStack
addStack :: Id -> Key -> Stack -> Either SomeException Stack
addStack :: Id -> Key -> Stack -> Either SomeException Stack
addStack i :: Id
i k :: Key
k (Stack _ ks :: [Either Key [String]]
ks is :: HashSet Id
is)
| Id
i Id -> HashSet Id -> Bool
forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
`Set.member` HashSet Id
is = SomeException -> Either SomeException Stack
forall a b. a -> Either a b
Left (SomeException -> Either SomeException Stack)
-> SomeException -> Either SomeException Stack
forall a b. (a -> b) -> a -> b
$ ShakeException -> SomeException
forall e. Exception e => e -> SomeException
toException (ShakeException -> SomeException)
-> ShakeException -> SomeException
forall a b. (a -> b) -> a -> b
$ Stack -> SomeException -> ShakeException
exceptionStack Stack
stack2 (SomeException -> ShakeException)
-> SomeException -> ShakeException
forall a b. (a -> b) -> a -> b
$ TypeRep -> String -> SomeException
errorRuleRecursion (Key -> TypeRep
typeKey Key
k) (Key -> String
forall a. Show a => a -> String
show Key
k)
| Bool
otherwise = Stack -> Either SomeException Stack
forall a b. b -> Either a b
Right Stack
stack2
where stack2 :: Stack
stack2 = Maybe Key -> [Either Key [String]] -> HashSet Id -> Stack
Stack (Key -> Maybe Key
forall a. a -> Maybe a
Just Key
k) (Key -> Either Key [String]
forall a b. a -> Either a b
Left Key
kEither Key [String]
-> [Either Key [String]] -> [Either Key [String]]
forall a. a -> [a] -> [a]
:[Either Key [String]]
ks) (Id -> HashSet Id -> HashSet Id
forall a. (Eq a, Hashable a) => a -> HashSet a -> HashSet a
Set.insert Id
i HashSet Id
is)
addCallStack :: [String] -> Stack -> Stack
addCallStack :: [String] -> Stack -> Stack
addCallStack xs :: [String]
xs (Stack t :: Maybe Key
t a :: [Either Key [String]]
a b :: HashSet Id
b) = Maybe Key -> [Either Key [String]] -> HashSet Id -> Stack
Stack Maybe Key
t ([String] -> Either Key [String]
forall a b. b -> Either a b
Right [String]
xs Either Key [String]
-> [Either Key [String]] -> [Either Key [String]]
forall a. a -> [a] -> [a]
: (Either Key [String] -> Bool)
-> [Either Key [String]] -> [Either Key [String]]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Either Key [String] -> Either Key [String] -> Bool
forall a. Eq a => a -> a -> Bool
== [String] -> Either Key [String]
forall a b. b -> Either a b
Right [String]
xs) [Either Key [String]]
a) HashSet Id
b
topStack :: Stack -> Maybe Key
topStack :: Stack -> Maybe Key
topStack (Stack t :: Maybe Key
t _ _) = Maybe Key
t
emptyStack :: Stack
emptyStack :: Stack
emptyStack = Maybe Key -> [Either Key [String]] -> HashSet Id -> Stack
Stack Maybe Key
forall a. Maybe a
Nothing [] HashSet Id
forall a. HashSet a
Set.empty
data Trace = Trace
{Trace -> ByteString
traceMessage :: {-# UNPACK #-} !BS.ByteString
,Trace -> Float
traceStart :: {-# UNPACK #-} !Float
,Trace -> Float
traceEnd :: {-# UNPACK #-} !Float
}
deriving Int -> Trace -> ShowS
[Trace] -> ShowS
Trace -> String
(Int -> Trace -> ShowS)
-> (Trace -> String) -> ([Trace] -> ShowS) -> Show Trace
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Trace] -> ShowS
$cshowList :: [Trace] -> ShowS
show :: Trace -> String
$cshow :: Trace -> String
showsPrec :: Int -> Trace -> ShowS
$cshowsPrec :: Int -> Trace -> ShowS
Show
instance NFData Trace where
rnf :: Trace -> ()
rnf x :: Trace
x = Trace
x Trace -> () -> ()
forall a b. a -> b -> b
`seq` ()
instance BinaryEx Trace where
putEx :: Trace -> Builder
putEx (Trace a :: ByteString
a b :: Float
b c :: Float
c) = Float -> Builder
forall a. BinaryEx a => a -> Builder
putEx Float
b Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Float -> Builder
forall a. BinaryEx a => a -> Builder
putEx Float
c Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ByteString -> Builder
forall a. BinaryEx a => a -> Builder
putEx ByteString
a
getEx :: ByteString -> Trace
getEx x :: ByteString
x | (b :: Float
b,c :: Float
c,a :: ByteString
a) <- ByteString -> (Float, Float, ByteString)
forall a b.
(Storable a, Storable b) =>
ByteString -> (a, b, ByteString)
binarySplit2 ByteString
x = ByteString -> Float -> Float -> Trace
Trace ByteString
a Float
b Float
c
instance BinaryEx [Trace] where
putEx :: [Trace] -> Builder
putEx = [Builder] -> Builder
putExList ([Builder] -> Builder)
-> ([Trace] -> [Builder]) -> [Trace] -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Trace -> Builder) -> [Trace] -> [Builder]
forall a b. (a -> b) -> [a] -> [b]
map Trace -> Builder
forall a. BinaryEx a => a -> Builder
putEx
getEx :: ByteString -> [Trace]
getEx = (ByteString -> Trace) -> [ByteString] -> [Trace]
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> Trace
forall a. BinaryEx a => ByteString -> a
getEx ([ByteString] -> [Trace])
-> (ByteString -> [ByteString]) -> ByteString -> [Trace]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
getExList
newTrace :: String -> Seconds -> Seconds -> Trace
newTrace :: String -> Seconds -> Seconds -> Trace
newTrace msg :: String
msg start :: Seconds
start stop :: Seconds
stop = ByteString -> Float -> Float -> Trace
Trace (String -> ByteString
BS.pack String
msg) (Seconds -> Float
doubleToFloat Seconds
start) (Seconds -> Float
doubleToFloat Seconds
stop)
type OneShot a = a
data Status
= Ready !(Result (Value, OneShot BS_Store))
| Failed !SomeException !(OneShot (Maybe (Result BS_Store)))
| Loaded !(Result BS_Store)
| Running !(NoShow (Either SomeException (Result (Value, BS_Store)) -> Locked ())) (Maybe (Result BS_Store))
| Missing
deriving Int -> Status -> ShowS
[Status] -> ShowS
Status -> String
(Int -> Status -> ShowS)
-> (Status -> String) -> ([Status] -> ShowS) -> Show Status
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Status] -> ShowS
$cshowList :: [Status] -> ShowS
show :: Status -> String
$cshow :: Status -> String
showsPrec :: Int -> Status -> ShowS
$cshowsPrec :: Int -> Status -> ShowS
Show
instance NFData Status where
rnf :: Status -> ()
rnf x :: Status
x = case Status
x of
Ready x :: Result (Value, ByteString)
x -> Result (Value, ByteString) -> ()
forall a. NFData a => a -> ()
rnf Result (Value, ByteString)
x
Failed x :: SomeException
x y :: OneShot (Maybe (Result ByteString))
y -> SomeException -> ()
rnfException SomeException
x () -> () -> ()
forall a b. a -> b -> b
`seq` OneShot (Maybe (Result ByteString)) -> ()
forall a. NFData a => a -> ()
rnf OneShot (Maybe (Result ByteString))
y
Loaded x :: Result ByteString
x -> Result ByteString -> ()
forall a. NFData a => a -> ()
rnf Result ByteString
x
Running _ x :: OneShot (Maybe (Result ByteString))
x -> OneShot (Maybe (Result ByteString)) -> ()
forall a. NFData a => a -> ()
rnf OneShot (Maybe (Result ByteString))
x
Missing -> ()
where
rnfException :: SomeException -> ()
rnfException = String -> ()
forall a. NFData a => a -> ()
rnf (String -> ()) -> (SomeException -> String) -> SomeException -> ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeException -> String
forall a. Show a => a -> String
show
data Result a = Result
{Result a -> a
result :: !a
,Result a -> Step
built :: {-# UNPACK #-} !Step
,Result a -> Step
changed :: {-# UNPACK #-} !Step
,Result a -> [Depends]
depends :: ![Depends]
,Result a -> Float
execution :: {-# UNPACK #-} !Float
,Result a -> [Trace]
traces :: ![Trace]
} deriving (Int -> Result a -> ShowS
[Result a] -> ShowS
Result a -> String
(Int -> Result a -> ShowS)
-> (Result a -> String) -> ([Result a] -> ShowS) -> Show (Result a)
forall a. Show a => Int -> Result a -> ShowS
forall a. Show a => [Result a] -> ShowS
forall a. Show a => Result a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Result a] -> ShowS
$cshowList :: forall a. Show a => [Result a] -> ShowS
show :: Result a -> String
$cshow :: forall a. Show a => Result a -> String
showsPrec :: Int -> Result a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Result a -> ShowS
Show,a -> Result b -> Result a
(a -> b) -> Result a -> Result b
(forall a b. (a -> b) -> Result a -> Result b)
-> (forall a b. a -> Result b -> Result a) -> Functor Result
forall a b. a -> Result b -> Result a
forall a b. (a -> b) -> Result a -> Result b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Result b -> Result a
$c<$ :: forall a b. a -> Result b -> Result a
fmap :: (a -> b) -> Result a -> Result b
$cfmap :: forall a b. (a -> b) -> Result a -> Result b
Functor)
instance NFData a => NFData (Result a) where
rnf :: Result a -> ()
rnf (Result a :: a
a _ _ b :: [Depends]
b _ c :: [Trace]
c) = a -> ()
forall a. NFData a => a -> ()
rnf a
a () -> () -> ()
forall a b. a -> b -> b
`seq` [Depends] -> ()
forall a. NFData a => a -> ()
rnf [Depends]
b () -> () -> ()
forall a b. a -> b -> b
`seq` [Trace] -> ()
forall a. NFData a => a -> ()
rnf [Trace]
c
statusType :: Status -> String
statusType Ready{} = "Ready"
statusType Failed{} = "Failed"
statusType Loaded{} = "Loaded"
statusType Running{} = "Running"
statusType Missing{} = "Missing"
getResult :: Status -> Maybe (Result (Either BS_Store Value))
getResult :: Status -> Maybe (Result (Either ByteString Value))
getResult (Ready r :: Result (Value, ByteString)
r) = Result (Either ByteString Value)
-> Maybe (Result (Either ByteString Value))
forall a. a -> Maybe a
Just (Result (Either ByteString Value)
-> Maybe (Result (Either ByteString Value)))
-> Result (Either ByteString Value)
-> Maybe (Result (Either ByteString Value))
forall a b. (a -> b) -> a -> b
$ Value -> Either ByteString Value
forall a b. b -> Either a b
Right (Value -> Either ByteString Value)
-> ((Value, ByteString) -> Value)
-> (Value, ByteString)
-> Either ByteString Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Value, ByteString) -> Value
forall a b. (a, b) -> a
fst ((Value, ByteString) -> Either ByteString Value)
-> Result (Value, ByteString) -> Result (Either ByteString Value)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result (Value, ByteString)
r
getResult (Loaded r :: Result ByteString
r) = Result (Either ByteString Value)
-> Maybe (Result (Either ByteString Value))
forall a. a -> Maybe a
Just (Result (Either ByteString Value)
-> Maybe (Result (Either ByteString Value)))
-> Result (Either ByteString Value)
-> Maybe (Result (Either ByteString Value))
forall a b. (a -> b) -> a -> b
$ ByteString -> Either ByteString Value
forall a b. a -> Either a b
Left (ByteString -> Either ByteString Value)
-> Result ByteString -> Result (Either ByteString Value)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Result ByteString
r
getResult (Running _ r :: OneShot (Maybe (Result ByteString))
r) = (ByteString -> Either ByteString Value)
-> Result ByteString -> Result (Either ByteString Value)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Either ByteString Value
forall a b. a -> Either a b
Left (Result ByteString -> Result (Either ByteString Value))
-> OneShot (Maybe (Result ByteString))
-> Maybe (Result (Either ByteString Value))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OneShot (Maybe (Result ByteString))
r
getResult _ = Maybe (Result (Either ByteString Value))
forall a. Maybe a
Nothing
newtype Depends = Depends {Depends -> [Id]
fromDepends :: [Id]}
deriving (Depends -> ()
(Depends -> ()) -> NFData Depends
forall a. (a -> ()) -> NFData a
rnf :: Depends -> ()
$crnf :: Depends -> ()
NFData, b -> Depends -> Depends
NonEmpty Depends -> Depends
Depends -> Depends -> Depends
(Depends -> Depends -> Depends)
-> (NonEmpty Depends -> Depends)
-> (forall b. Integral b => b -> Depends -> Depends)
-> Semigroup Depends
forall b. Integral b => b -> Depends -> Depends
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> Depends -> Depends
$cstimes :: forall b. Integral b => b -> Depends -> Depends
sconcat :: NonEmpty Depends -> Depends
$csconcat :: NonEmpty Depends -> Depends
<> :: Depends -> Depends -> Depends
$c<> :: Depends -> Depends -> Depends
Semigroup, Semigroup Depends
Depends
Semigroup Depends =>
Depends
-> (Depends -> Depends -> Depends)
-> ([Depends] -> Depends)
-> Monoid Depends
[Depends] -> Depends
Depends -> Depends -> Depends
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [Depends] -> Depends
$cmconcat :: [Depends] -> Depends
mappend :: Depends -> Depends -> Depends
$cmappend :: Depends -> Depends -> Depends
mempty :: Depends
$cmempty :: Depends
$cp1Monoid :: Semigroup Depends
Monoid)
instance Show Depends where
show :: Depends -> String
show = [Id] -> String
forall a. Show a => a -> String
show ([Id] -> String) -> (Depends -> [Id]) -> Depends -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Depends -> [Id]
fromDepends
instance BinaryEx Depends where
putEx :: Depends -> Builder
putEx (Depends xs :: [Id]
xs) = [Id] -> Builder
forall a. Storable a => [a] -> Builder
putExStorableList [Id]
xs
getEx :: ByteString -> Depends
getEx = [Id] -> Depends
Depends ([Id] -> Depends) -> (ByteString -> [Id]) -> ByteString -> Depends
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [Id]
forall a. Storable a => ByteString -> [a]
getExStorableList
instance BinaryEx [Depends] where
putEx :: [Depends] -> Builder
putEx = [Builder] -> Builder
putExList ([Builder] -> Builder)
-> ([Depends] -> [Builder]) -> [Depends] -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Depends -> Builder) -> [Depends] -> [Builder]
forall a b. (a -> b) -> [a] -> [b]
map Depends -> Builder
forall a. BinaryEx a => a -> Builder
putEx
getEx :: ByteString -> [Depends]
getEx = (ByteString -> Depends) -> [ByteString] -> [Depends]
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> Depends
forall a. BinaryEx a => ByteString -> a
getEx ([ByteString] -> [Depends])
-> (ByteString -> [ByteString]) -> ByteString -> [Depends]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
getExList
nubDepends :: [Depends] -> [Depends]
nubDepends :: [Depends] -> [Depends]
nubDepends = HashSet Id -> [Depends] -> [Depends]
fMany HashSet Id
forall a. HashSet a
Set.empty
where
fMany :: HashSet Id -> [Depends] -> [Depends]
fMany _ [] = []
fMany seen :: HashSet Id
seen (Depends d :: [Id]
d:ds :: [Depends]
ds) = [[Id] -> Depends
Depends [Id]
d2 | [Id]
d2 [Id] -> [Id] -> Bool
forall a. Eq a => a -> a -> Bool
/= []] [Depends] -> [Depends] -> [Depends]
forall a. [a] -> [a] -> [a]
++ HashSet Id -> [Depends] -> [Depends]
fMany HashSet Id
seen2 [Depends]
ds
where (d2 :: [Id]
d2,seen2 :: HashSet Id
seen2) = HashSet Id -> [Id] -> ([Id], HashSet Id)
forall a.
(Eq a, Hashable a) =>
HashSet a -> [a] -> ([a], HashSet a)
fOne HashSet Id
seen [Id]
d
fOne :: HashSet a -> [a] -> ([a], HashSet a)
fOne seen :: HashSet a
seen [] = ([], HashSet a
seen)
fOne seen :: HashSet a
seen (x :: a
x:xs :: [a]
xs) | a
x a -> HashSet a -> Bool
forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
`Set.member` HashSet a
seen = HashSet a -> [a] -> ([a], HashSet a)
fOne HashSet a
seen [a]
xs
fOne seen :: HashSet a
seen (x :: a
x:xs :: [a]
xs) = ([a] -> [a]) -> ([a], HashSet a) -> ([a], HashSet a)
forall a a' b. (a -> a') -> (a, b) -> (a', b)
first (a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:) (([a], HashSet a) -> ([a], HashSet a))
-> ([a], HashSet a) -> ([a], HashSet a)
forall a b. (a -> b) -> a -> b
$ HashSet a -> [a] -> ([a], HashSet a)
fOne (a -> HashSet a -> HashSet a
forall a. (Eq a, Hashable a) => a -> HashSet a -> HashSet a
Set.insert a
x HashSet a
seen) [a]
xs
type BuiltinRun key value
= key
-> Maybe BS.ByteString
-> RunMode
-> Action (RunResult value)
type BuiltinLint key value = key -> value -> IO (Maybe String)
type BuiltinIdentity key value = key -> value -> Maybe BS.ByteString
data BuiltinRule = BuiltinRule
{BuiltinRule -> BuiltinLint Key Value
builtinLint :: BuiltinLint Key Value
,BuiltinRule -> BuiltinIdentity Key Value
builtinIdentity :: BuiltinIdentity Key Value
,BuiltinRule -> BuiltinRun Key Value
builtinRun :: BuiltinRun Key Value
,BuiltinRule -> BinaryOp Key
builtinKey :: BinaryOp Key
,BuiltinRule -> Ver
builtinVersion :: Ver
,BuiltinRule -> String
builtinLocation :: String
}
data UserRule a
= UserRule a
| Unordered [UserRule a]
| Priority Double (UserRule a)
| Alternative (UserRule a)
| Versioned Ver (UserRule a)
deriving (UserRule a -> UserRule a -> Bool
(UserRule a -> UserRule a -> Bool)
-> (UserRule a -> UserRule a -> Bool) -> Eq (UserRule a)
forall a. Eq a => UserRule a -> UserRule a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserRule a -> UserRule a -> Bool
$c/= :: forall a. Eq a => UserRule a -> UserRule a -> Bool
== :: UserRule a -> UserRule a -> Bool
$c== :: forall a. Eq a => UserRule a -> UserRule a -> Bool
Eq,Int -> UserRule a -> ShowS
[UserRule a] -> ShowS
UserRule a -> String
(Int -> UserRule a -> ShowS)
-> (UserRule a -> String)
-> ([UserRule a] -> ShowS)
-> Show (UserRule a)
forall a. Show a => Int -> UserRule a -> ShowS
forall a. Show a => [UserRule a] -> ShowS
forall a. Show a => UserRule a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserRule a] -> ShowS
$cshowList :: forall a. Show a => [UserRule a] -> ShowS
show :: UserRule a -> String
$cshow :: forall a. Show a => UserRule a -> String
showsPrec :: Int -> UserRule a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> UserRule a -> ShowS
Show,a -> UserRule b -> UserRule a
(a -> b) -> UserRule a -> UserRule b
(forall a b. (a -> b) -> UserRule a -> UserRule b)
-> (forall a b. a -> UserRule b -> UserRule a) -> Functor UserRule
forall a b. a -> UserRule b -> UserRule a
forall a b. (a -> b) -> UserRule a -> UserRule b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> UserRule b -> UserRule a
$c<$ :: forall a b. a -> UserRule b -> UserRule a
fmap :: (a -> b) -> UserRule a -> UserRule b
$cfmap :: forall a b. (a -> b) -> UserRule a -> UserRule b
Functor,Typeable)
data UserRuleVersioned a = UserRuleVersioned
{UserRuleVersioned a -> Bool
userRuleVersioned :: Bool
,UserRuleVersioned a -> UserRule a
userRuleContents :: UserRule a
}
instance Semigroup (UserRuleVersioned a) where
UserRuleVersioned b1 :: Bool
b1 x1 :: UserRule a
x1 <> :: UserRuleVersioned a -> UserRuleVersioned a -> UserRuleVersioned a
<> UserRuleVersioned b2 :: Bool
b2 x2 :: UserRule a
x2 = Bool -> UserRule a -> UserRuleVersioned a
forall a. Bool -> UserRule a -> UserRuleVersioned a
UserRuleVersioned (Bool
b1 Bool -> Bool -> Bool
|| Bool
b2) (UserRule a
x1 UserRule a -> UserRule a -> UserRule a
forall a. Semigroup a => a -> a -> a
<> UserRule a
x2)
instance Monoid (UserRuleVersioned a) where
mempty :: UserRuleVersioned a
mempty = Bool -> UserRule a -> UserRuleVersioned a
forall a. Bool -> UserRule a -> UserRuleVersioned a
UserRuleVersioned Bool
False UserRule a
forall a. Monoid a => a
mempty
mappend :: UserRuleVersioned a -> UserRuleVersioned a -> UserRuleVersioned a
mappend = UserRuleVersioned a -> UserRuleVersioned a -> UserRuleVersioned a
forall a. Semigroup a => a -> a -> a
(<>)
instance Semigroup (UserRule a) where
x :: UserRule a
x <> :: UserRule a -> UserRule a -> UserRule a
<> y :: UserRule a
y = [UserRule a] -> UserRule a
forall a. [UserRule a] -> UserRule a
Unordered [UserRule a
x,UserRule a
y]
instance Monoid (UserRule a) where
mempty :: UserRule a
mempty = [UserRule a] -> UserRule a
forall a. [UserRule a] -> UserRule a
Unordered []
mappend :: UserRule a -> UserRule a -> UserRule a
mappend = UserRule a -> UserRule a -> UserRule a
forall a. Semigroup a => a -> a -> a
(<>)
userRuleSize :: UserRule a -> Int
userRuleSize :: UserRule a -> Int
userRuleSize UserRule{} = 1
userRuleSize (Unordered xs :: [UserRule a]
xs) = [Int] -> Int
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ (UserRule a -> Int) -> [UserRule a] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map UserRule a -> Int
forall a. UserRule a -> Int
userRuleSize [UserRule a]
xs
userRuleSize (Priority _ x :: UserRule a
x) = UserRule a -> Int
forall a. UserRule a -> Int
userRuleSize UserRule a
x
userRuleSize (Alternative x :: UserRule a
x) = UserRule a -> Int
forall a. UserRule a -> Int
userRuleSize UserRule a
x
userRuleSize (Versioned _ x :: UserRule a
x) = UserRule a -> Int
forall a. UserRule a -> Int
userRuleSize UserRule a
x
type Database = DatabasePoly Key Status
data Global = Global
{Global -> [String] -> [Key] -> Action [Value]
globalBuild :: [String] -> [Key] -> Action [Value]
,Global -> Database
globalDatabase :: Database
,Global -> Pool
globalPool :: Pool
,Global -> Cleanup
globalCleanup :: Cleanup
,Global -> IO Seconds
globalTimestamp :: IO Seconds
,Global -> HashMap TypeRep BuiltinRule
globalRules :: Map.HashMap TypeRep BuiltinRule
,Global -> Verbosity -> String -> IO ()
globalOutput :: Verbosity -> String -> IO ()
,Global -> ShakeOptions
globalOptions :: ShakeOptions
,Global -> IO String -> IO ()
globalDiagnostic :: IO String -> IO ()
,Global -> Key -> Action ()
globalRuleFinished :: Key -> Action ()
,Global -> IORef [IO ()]
globalAfter :: IORef [IO ()]
,Global -> IORef [(Key, Key)]
globalTrackAbsent :: IORef [(Key, Key)]
,Global -> IO Progress
globalProgress :: IO Progress
,Global -> Map UserRuleVersioned
globalUserRules :: TMap.Map UserRuleVersioned
,Global -> Maybe Shared
globalShared :: Maybe Shared
,Global -> Maybe Cloud
globalCloud :: Maybe Cloud
,Global -> Step
globalStep :: {-# UNPACK #-} !Step
,Global -> Bool
globalOneShot :: Bool
}
data Local = Local
{Local -> Stack
localStack :: Stack
,Local -> Ver
localBuiltinVersion :: Ver
,Local -> Verbosity
localVerbosity :: Verbosity
,Local -> Maybe String
localBlockApply :: Maybe String
,Local -> [Depends]
localDepends :: [Depends]
,Local -> Seconds
localDiscount :: !Seconds
,Local -> [Trace]
localTraces :: [Trace]
,Local -> [Key -> Bool]
localTrackAllows :: [Key -> Bool]
,Local -> [Key]
localTrackRead :: [Key]
,Local -> [Key]
localTrackWrite :: [Key]
,Local -> [(Bool, String)]
localProduces :: [(Bool, FilePath)]
,Local -> Bool
localHistory :: !Bool
}
addDiscount :: Seconds -> Local -> Local
addDiscount :: Seconds -> Local -> Local
addDiscount s :: Seconds
s l :: Local
l = Local
l{localDiscount :: Seconds
localDiscount = Seconds
s Seconds -> Seconds -> Seconds
forall a. Num a => a -> a -> a
+ Local -> Seconds
localDiscount Local
l}
newLocal :: Stack -> Verbosity -> Local
newLocal :: Stack -> Verbosity -> Local
newLocal stack :: Stack
stack verb :: Verbosity
verb = Stack
-> Ver
-> Verbosity
-> Maybe String
-> [Depends]
-> Seconds
-> [Trace]
-> [Key -> Bool]
-> [Key]
-> [Key]
-> [(Bool, String)]
-> Bool
-> Local
Local Stack
stack (Int -> Ver
Ver 0) Verbosity
verb Maybe String
forall a. Maybe a
Nothing [] 0 [] [] [] [] [] Bool
True
localClearMutable :: Local -> Local
localClearMutable :: Local -> Local
localClearMutable Local{..} = (Stack -> Verbosity -> Local
newLocal Stack
localStack Verbosity
localVerbosity){localBlockApply :: Maybe String
localBlockApply=Maybe String
localBlockApply, localBuiltinVersion :: Ver
localBuiltinVersion=Ver
localBuiltinVersion}
localMergeMutable :: Local -> [Local] -> Local
localMergeMutable :: Local -> [Local] -> Local
localMergeMutable root :: Local
root xs :: [Local]
xs = $WLocal :: Stack
-> Ver
-> Verbosity
-> Maybe String
-> [Depends]
-> Seconds
-> [Trace]
-> [Key -> Bool]
-> [Key]
-> [Key]
-> [(Bool, String)]
-> Bool
-> Local
Local
{localStack :: Stack
localStack = Local -> Stack
localStack Local
root
,localBuiltinVersion :: Ver
localBuiltinVersion = Local -> Ver
localBuiltinVersion Local
root
,localVerbosity :: Verbosity
localVerbosity = Local -> Verbosity
localVerbosity Local
root
,localBlockApply :: Maybe String
localBlockApply = Local -> Maybe String
localBlockApply Local
root
,localDepends :: [Depends]
localDepends = [[Depends]] -> [Depends]
mergeDependsRev ((Local -> [Depends]) -> [Local] -> [[Depends]]
forall a b. (a -> b) -> [a] -> [b]
map Local -> [Depends]
localDepends [Local]
xs) [Depends] -> [Depends] -> [Depends]
forall a. [a] -> [a] -> [a]
++ Local -> [Depends]
localDepends Local
root
,localDiscount :: Seconds
localDiscount = [Seconds] -> Seconds
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ([Seconds] -> Seconds) -> [Seconds] -> Seconds
forall a b. (a -> b) -> a -> b
$ (Local -> Seconds) -> [Local] -> [Seconds]
forall a b. (a -> b) -> [a] -> [b]
map Local -> Seconds
localDiscount ([Local] -> [Seconds]) -> [Local] -> [Seconds]
forall a b. (a -> b) -> a -> b
$ Local
root Local -> [Local] -> [Local]
forall a. a -> [a] -> [a]
: [Local]
xs
,localTraces :: [Trace]
localTraces = [[Trace]] -> [Trace]
mergeTracesRev ((Local -> [Trace]) -> [Local] -> [[Trace]]
forall a b. (a -> b) -> [a] -> [b]
map Local -> [Trace]
localTraces [Local]
xs) [Trace] -> [Trace] -> [Trace]
forall a. [a] -> [a] -> [a]
++ Local -> [Trace]
localTraces Local
root
,localTrackAllows :: [Key -> Bool]
localTrackAllows = Local -> [Key -> Bool]
localTrackAllows Local
root [Key -> Bool] -> [Key -> Bool] -> [Key -> Bool]
forall a. [a] -> [a] -> [a]
++ (Local -> [Key -> Bool]) -> [Local] -> [Key -> Bool]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Local -> [Key -> Bool]
localTrackAllows [Local]
xs
,localTrackRead :: [Key]
localTrackRead = Local -> [Key]
localTrackRead Local
root [Key] -> [Key] -> [Key]
forall a. [a] -> [a] -> [a]
++ (Local -> [Key]) -> [Local] -> [Key]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Local -> [Key]
localTrackRead [Local]
xs
,localTrackWrite :: [Key]
localTrackWrite = Local -> [Key]
localTrackWrite Local
root [Key] -> [Key] -> [Key]
forall a. [a] -> [a] -> [a]
++ (Local -> [Key]) -> [Local] -> [Key]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Local -> [Key]
localTrackWrite [Local]
xs
,localProduces :: [(Bool, String)]
localProduces = (Local -> [(Bool, String)]) -> [Local] -> [(Bool, String)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Local -> [(Bool, String)]
localProduces [Local]
xs [(Bool, String)] -> [(Bool, String)] -> [(Bool, String)]
forall a. [a] -> [a] -> [a]
++ Local -> [(Bool, String)]
localProduces Local
root
,localHistory :: Bool
localHistory = (Local -> Bool) -> [Local] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Local -> Bool
localHistory ([Local] -> Bool) -> [Local] -> Bool
forall a b. (a -> b) -> a -> b
$ Local
rootLocal -> [Local] -> [Local]
forall a. a -> [a] -> [a]
:[Local]
xs
}
mergeDependsRev :: [[Depends]] -> [Depends]
mergeDependsRev :: [[Depends]] -> [Depends]
mergeDependsRev = [Depends] -> [Depends]
forall a. [a] -> [a]
reverse ([Depends] -> [Depends])
-> ([[Depends]] -> [Depends]) -> [[Depends]] -> [Depends]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Depends]] -> [Depends]
forall a. Monoid a => [[a]] -> [a]
f ([[Depends]] -> [Depends])
-> ([[Depends]] -> [[Depends]]) -> [[Depends]] -> [Depends]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Depends] -> [Depends]) -> [[Depends]] -> [[Depends]]
forall a b. (a -> b) -> [a] -> [b]
map [Depends] -> [Depends]
forall a. [a] -> [a]
reverse
where
f :: [[a]] -> [a]
f [] = []
f xs :: [[a]]
xs = [a] -> a
forall a. Monoid a => [a] -> a
mconcat [a]
now a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [[a]] -> [a]
f [[a]]
next
where (now :: [a]
now, next :: [[a]]
next) = [(a, [a])] -> ([a], [[a]])
forall a b. [(a, b)] -> ([a], [b])
unzip ([(a, [a])] -> ([a], [[a]])) -> [(a, [a])] -> ([a], [[a]])
forall a b. (a -> b) -> a -> b
$ ([a] -> Maybe (a, [a])) -> [[a]] -> [(a, [a])]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe [a] -> Maybe (a, [a])
forall a. [a] -> Maybe (a, [a])
uncons [[a]]
xs
mergeTracesRev :: [[Trace]] -> [Trace]
mergeTracesRev :: [[Trace]] -> [Trace]
mergeTracesRev = [[Trace]] -> [Trace]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat