|
| 1 | +{-# LANGUAGE GeneralizedNewtypeDeriving #-} |
| 2 | +{-# LANGUAGE TypeFamilies #-} |
| 3 | + |
| 4 | +module Development.IDE.Graph.Internal.Action where |
| 5 | + |
| 6 | +import qualified Development.Shake as Shake |
| 7 | +import qualified Development.Shake.Rule as Shake |
| 8 | +import Development.Shake.Classes |
| 9 | +import Control.Exception |
| 10 | +import Control.Monad.IO.Class |
| 11 | +import Control.Monad.Fail |
| 12 | + |
| 13 | +newtype Action a = Action {fromAction :: Shake.Action a} |
| 14 | + deriving (Monad, Applicative, Functor, MonadIO, MonadFail) |
| 15 | + |
| 16 | +alwaysRerun :: Action () |
| 17 | +alwaysRerun = Action Shake.alwaysRerun |
| 18 | + |
| 19 | +reschedule :: Double -> Action () |
| 20 | +reschedule = Action . Shake.reschedule |
| 21 | + |
| 22 | +parallel :: [Action a] -> Action [a] |
| 23 | +parallel = Action . Shake.parallel . map fromAction |
| 24 | + |
| 25 | +actionCatch :: Exception e => Action a -> (e -> Action a) -> Action a |
| 26 | +actionCatch a b = Action $ Shake.actionCatch (fromAction a) (fromAction . b) |
| 27 | + |
| 28 | +actionBracket :: IO a -> (a -> IO b) -> (a -> Action c) -> Action c |
| 29 | +actionBracket a b c = Action $ Shake.actionBracket a b (fromAction . c) |
| 30 | + |
| 31 | +actionFinally :: Action a -> IO b -> Action a |
| 32 | +actionFinally a b = Action $ Shake.actionFinally (fromAction a) b |
| 33 | + |
| 34 | +apply1 :: (Shake.RuleResult key ~ value, Shake.ShakeValue key, Typeable value) => key -> Action value |
| 35 | +apply1 = Action . Shake.apply1 |
| 36 | + |
| 37 | +apply :: (Shake.RuleResult key ~ value, Shake.ShakeValue key, Typeable value) => [key] -> Action [value] |
| 38 | +apply = Action . Shake.apply |
0 commit comments