shake-plus (empty) → 0.0.1.0
raw patch · 16 files changed
+530/−0 lines, 16 filesdep +basedep +extradep +pathsetup-changed
Dependencies added: base, extra, path, rio, shake
Files
- ChangeLog.md +9/−0
- LICENSE +30/−0
- README.md +24/−0
- Setup.hs +2/−0
- shake-plus.cabal +48/−0
- src/Development/Shake/Plus.hs +15/−0
- src/Development/Shake/Plus/Cache.hs +18/−0
- src/Development/Shake/Plus/Config.hs +38/−0
- src/Development/Shake/Plus/Core.hs +90/−0
- src/Development/Shake/Plus/Database.hs +49/−0
- src/Development/Shake/Plus/Directory.hs +34/−0
- src/Development/Shake/Plus/Env.hs +22/−0
- src/Development/Shake/Plus/File.hs +55/−0
- src/Development/Shake/Plus/FileRules.hs +29/−0
- src/Development/Shake/Plus/Oracle.hs +40/−0
- src/Development/Shake/Plus/Temp.hs +27/−0
+ ChangeLog.md view
@@ -0,0 +1,9 @@+# Changelog for shake-plus++## v0.0.1.0++* Initial sketch of shake-plus with reexported functions. Mostly oracles,+ filepaths and directory functions using+ [Path](https://hackage.haskell.org/package/path), and `MonadAction`,+ `MonadUnliftAction` and `MonadRules` with `ReaderT` transformers in a similar+ style to [RIO](https://hackage.haskell.org/package/rio)
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Author name here (c) 2020++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Author name here nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,24 @@+# Shake+ - Super Powered Shake++Attempt at a batteries included Shake. We reexport replacements for the main+utility functions of Shake with the following adjustments whereever possible.++* Well-typed paths using the [path](https://hackage.haskell.org/package/path)+* New type classes `MonadAction`,`MonadUnliftAction` and `MonadRules` with+ stock `ReaderT` transformers.+* `Text` instead of `String` wherever it is appropriate.++Unlifting `Action`s is a challenge when we cross monad boundaries (from+`Action` to `Rules`), and so some functions are hard coded against the+`RAction` type, which is a hardcoded newtype `ReaderT r Action a`. This is+annoying, but it's sufficient to add your own logging and reader lenses. It+may be possible to generalize this with some unlifting contortion but so far I+haven't been able to figure it out.++The main entry point ot this library is the `runShakePlus` function, which+collapses a `ReaderT r Rules ()` to a `Rules ()` and passes the environment to+each underlying `RAction`.++This is an early release and a lot of things may be missing or broken, but so+far the conveniences have been worth it. Until it's stable/complete you probaly+want to `import qualified Development.Shake` to deal with any missing parts.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ shake-plus.cabal view
@@ -0,0 +1,48 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 2c3973cab1afdf468a1a38cb29ab3fa3fd78d0112dc8fabc32eaf14949e34860++name: shake-plus+version: 0.0.1.0+synopsis: Re-export of Shake using well-typed paths and ReaderT.+description: Re-export of Shake using well-typed paths and ReaderT. This is an early release so some things may be missing or broken but so far the conveniences have been worth it.+category: development, shake+author: Daniel Firth+maintainer: dan.firth@homotopic.tech+copyright: 2020 Daniel Firth+license: MIT+license-file: LICENSE+build-type: Simple+extra-source-files:+ README.md+ ChangeLog.md++library+ exposed-modules:+ Development.Shake.Plus+ Development.Shake.Plus.Cache+ Development.Shake.Plus.Config+ Development.Shake.Plus.Core+ Development.Shake.Plus.Database+ Development.Shake.Plus.Directory+ Development.Shake.Plus.Env+ Development.Shake.Plus.File+ Development.Shake.Plus.FileRules+ Development.Shake.Plus.Oracle+ Development.Shake.Plus.Temp+ other-modules:+ Paths_shake_plus+ hs-source-dirs:+ src+ default-extensions: BangPatterns BinaryLiterals ConstraintKinds DataKinds DefaultSignatures DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DoAndIfThenElse EmptyDataDecls ExistentialQuantification FlexibleContexts FlexibleInstances FunctionalDependencies GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PartialTypeSignatures PatternGuards PolyKinds RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TupleSections TypeFamilies TypeSynonymInstances ViewPatterns+ build-depends:+ base >=4.7 && <5+ , extra+ , path+ , rio+ , shake+ default-language: Haskell2010
+ src/Development/Shake/Plus.hs view
@@ -0,0 +1,15 @@+module Development.Shake.Plus (+ module Development.Shake.Plus.Cache+ module Development.Shake.Plus.Core+, module Development.Shake.Plus.Directory+, module Development.Shake.Plus.File+, module Development.Shake.Plus.FileRules+, module Development.Shake.Plus.Orcle+) where++import Development.Shake.Plus.Cache+import Development.Shake.Plus.Core+import Development.Shake.Plus.File+import Development.Shake.Plus.FileRules+import Development.Shake.Plus.Directory+import Development.Shake.Plus.Oracle
+ src/Development/Shake/Plus/Cache.hs view
@@ -0,0 +1,18 @@+module Development.Shake.Plus.Cache (+ newCache+, newCacheIO+) where++import qualified Development.Shake+import RIO+import Development.Shake.Plus.Core++-- | Lifted version of `Development.Shake.newCache` using `RAction`.+newCache :: (MonadRules m, MonadReader r m, Eq k, Hashable k)+ => (k -> RAction r v)+ -> m (k -> RAction r v)+newCache ract = ask >>= \r -> liftRules $ (liftAction . ) <$> Development.Shake.newCache (runRAction r . ract)++-- | Lifted version of `Development.Shake.newCacheIO` using `RAction`.+newCacheIO :: (MonadIO m, MonadReader r m, Eq k, Hashable k) => (k -> RAction r v) -> m (k -> RAction r v)+newCacheIO f = ask >>= \r -> liftIO $ (liftAction . ) <$> Development.Shake.newCacheIO (\y -> runRAction r (f y))
+ src/Development/Shake/Plus/Config.hs view
@@ -0,0 +1,38 @@+module Development.Shake.Plus.Config (+ readConfigFile+, readConfigFileWithEnv+, usingConfigFile+, usingConfig+, getConfig+, getConfigKeys+) where++import Development.Shake+import qualified Development.Shake.Config+import Development.Shake.Plus.Core+import Path+import RIO++-- | Lifted `Development.Shake.Config.readConfigFile` with well-typed path.+readConfigFile :: MonadIO m => Path a File -> m (HashMap String String)+readConfigFile = liftIO . Development.Shake.Config.readConfigFile . toFilePath++-- | Lifted `Development.Shake.Config.readConfigFileWithEnv` with well-typed path.+readConfigFileWithEnv :: MonadIO m => [(String, String)] -> Path a File -> m (HashMap String String)+readConfigFileWithEnv vars file = liftIO $ Development.Shake.Config.readConfigFileWithEnv vars (toFilePath file)++-- | Lifted `Development.Shake.Config.usingConfigFile` with well-typed path.+usingConfigFile :: MonadRules m => Path a File -> m ()+usingConfigFile = liftRules . Development.Shake.Config.usingConfigFile . toFilePath++-- | Lifted `Development.Shake.Config.usingConfig`.+usingConfig :: MonadRules m => HashMap String String -> m ()+usingConfig = liftRules . Development.Shake.Config.usingConfig++-- | Lifted `Development.Shake.Config.getConfig`.+getConfig :: MonadAction m => String -> m (Maybe String)+getConfig = liftAction . Development.Shake.Config.getConfig++-- | Lifted `Development.Shake.Config.getConfigKeys`.+getConfigKeys :: MonadAction m => m [String]+getConfigKeys = liftAction $ Development.Shake.Config.getConfigKeys
+ src/Development/Shake/Plus/Core.hs view
@@ -0,0 +1,90 @@+module Development.Shake.Plus.Core (+ MonadAction(..)+, MonadRules(..)+, UnliftAction(..)+, MonadUnliftAction(..)+, withUnliftAction+, askUnliftAction+, toAction+, RAction+, ShakePlus+, runRAction+, runShakePlus+) where++import Control.Exception+import Development.Shake (Action, Rules)+import RIO++-- | Monads in which `Action`s may be embedded.+class Monad m => MonadAction m where+ liftAction :: Action a -> m a++instance MonadAction Action where+ liftAction = id++instance MonadAction m => MonadAction (ReaderT r m) where+ liftAction = lift . liftAction++newtype UnliftAction m = UnliftAction { unliftAction :: forall a. m a -> Action a }++-- | Monads which allow their actions to be run in 'Action'.+--+-- For the same reasons as `MonadUnliftIO` this is limited to 'ReaderT'+-- and `IdentityT` transformers on top of `Action'.+class MonadAction m => MonadUnliftAction m where+ {-# INLINE withRunInAction #-}+ withRunInAction :: ((forall a. m a -> Action a) -> Action b) -> m b+ withRunInAction inner = askUnliftAction >>= \u -> liftAction (inner (unliftAction u))++instance MonadUnliftAction Action where+ {-# INLINE withRunInAction #-}+ withRunInAction inner = inner id++instance MonadUnliftAction m => MonadUnliftAction (ReaderT r m) where+ {-# INLINE withRunInAction #-}+ withRunInAction inner =+ ReaderT $ \r ->+ withRunInAction $ \run ->+ inner (run . flip runReaderT r)++class Monad m => MonadRules m where+ liftRules :: Rules a -> m a++instance MonadRules Rules where+ liftRules = id++instance MonadRules m => MonadRules (ReaderT r m) where+ liftRules = lift . liftRules++withUnliftAction :: MonadUnliftAction m => (UnliftAction m -> Action a) -> m a+withUnliftAction inner = askUnliftAction >>= liftAction . inner++askUnliftAction :: MonadUnliftAction m => m (UnliftAction m)+askUnliftAction = withRunInAction (\run -> return (UnliftAction run))++toAction :: MonadUnliftAction m => m a -> m (Action a)+toAction m = withRunInAction $ \run -> return $ run m++-- | Concrete `Action` runner, hardcoded to `ReaderT r Action a`.+newtype RAction r a = RAction (ReaderT r Action a)+ deriving (Functor, Applicative, Monad, MonadReader r, MonadIO, MonadAction, MonadUnliftAction)++-- | Concrete `Rules` collector, hardcoded to `ReaderT r Rules a`.+newtype ShakePlus r a = ShakePlus (ReaderT r Rules a)+ deriving (Functor, Applicative, Monad, MonadReader r, MonadIO, MonadRules)++-- | Run an `RAction` with an environment, consuming it for a result.+runRAction :: MonadAction m => env -> RAction env a -> m a+runRAction env (RAction (ReaderT f)) = liftAction (f env)++-- | Run a `ShakePlus` with an environment, consuming it for some Shake `Rules`.+runShakePlus :: MonadRules m => env -> ShakePlus env a -> m a +runShakePlus env (ShakePlus (ReaderT f)) = liftRules (f env)++instance MonadThrow (RAction r) where+ throwM = liftIO . Control.Exception.throwIO++instance MonadThrow (ShakePlus r) where+ throwM = liftIO . Control.Exception.throwIO+
+ src/Development/Shake/Plus/Database.hs view
@@ -0,0 +1,49 @@+module Development.Shake.Plus.Database (+ Development.Shake.Database.ShakeDatabase+, shakeOpenDatabase+, shakeWithDatabase+, shakeOneShotDatabase+, shakeRunDatabase+, shakeLiveFilesDatabase+, shakeProfileDatabase+, shakeErrorsDatabase+, shakeRunAfter+) where++import Development.Shake (ShakeOptions, Action, Rules)+import Development.Shake.Database (ShakeDatabase)+import qualified Development.Shake.Database+import Path+import RIO++-- | Lifted `Development.Shake.Database.shakeOpenDatabase`+shakeOpenDatabase :: MonadIO m => ShakeOptions -> Rules () -> m (IO ShakeDatabase, IO ())+shakeOpenDatabase opts rules = liftIO $ Development.Shake.Database.shakeOpenDatabase opts rules++-- | Unlifted `Development.Shake.Database.shakeWithDatabase`+shakeWithDatabase :: MonadUnliftIO m => ShakeOptions -> Rules () -> (ShakeDatabase -> m a) -> m a+shakeWithDatabase opts rules inner = withRunInIO $ \run -> Development.Shake.Database.shakeWithDatabase opts rules $ run . inner++-- | Lifted `Development.Shake.Database.shakeOneShotDatabase`+shakeOneShotDatabase :: MonadIO m => ShakeDatabase -> m ()+shakeOneShotDatabase = liftIO . Development.Shake.Database.shakeOneShotDatabase++-- | Lifted `Development.Shake.Database.shakeRunDatabase`+shakeRunDatabase :: MonadIO m => ShakeDatabase -> [Action a] -> m ([a], [IO ()])+shakeRunDatabase db actions = liftIO $ shakeRunDatabase db actions++-- | Lifted `Development.Shake.Database.shakeLiveFilesDatabase`+shakeLiveFilesDatabase :: MonadIO m => ShakeDatabase -> m [FilePath]+shakeLiveFilesDatabase = liftIO . Development.Shake.Database.shakeLiveFilesDatabase++-- | Lifted `Development.Shake.Database.shakeProfileDatabase` with well-typed path.+shakeProfileDatabase :: MonadIO m => ShakeDatabase -> Path a File -> m ()+shakeProfileDatabase db file = liftIO $ Development.Shake.Database.shakeProfileDatabase db (toFilePath file)++-- | Lifted `Development.Shake.Database.shakeErrorsDatabase`+shakeErrorsDatabase :: MonadIO m => ShakeDatabase -> m [(String, SomeException)]+shakeErrorsDatabase = liftIO . Development.Shake.Database.shakeErrorsDatabase++-- | Unlifted `Development.Shake.Database.shakeRunAfter`+shakeRunAfter :: MonadUnliftIO m => ShakeOptions -> [m ()] -> m ()+shakeRunAfter opts inners = withRunInIO $ \run -> Development.Shake.Database.shakeRunAfter opts $ fmap run inners
+ src/Development/Shake/Plus/Directory.hs view
@@ -0,0 +1,34 @@+module Development.Shake.Plus.Directory (+ doesFileExist+, doesDirectoryExist+, getDirectoryFiles+, getDirectoryDirs+, getDirectoryFilesIO+) where++import Control.Exception.Extra+import Development.Shake.Plus.Core+import qualified Development.Shake+import Development.Shake (FilePattern)+import RIO+import Path++-- | Lifted version of `Development.Shake.doesFileExist` using well-typed `Path`s.+doesFileExist :: MonadAction m => Path b File -> m Bool+doesFileExist = liftAction . Development.Shake.doesFileExist . toFilePath++-- | Lifted version of `Development.Shake.doesDirectoryExist` using well-typed `Path`s.+doesDirectoryExist :: MonadAction m => Path b Dir -> m Bool+doesDirectoryExist = liftAction . Development.Shake.doesDirectoryExist . toFilePath++-- | Lifted version of `Development.Shake.getDirectoryFiles` using well-typed `Path`s.+getDirectoryFiles :: MonadAction m => Path b Dir -> [FilePattern] -> m [Path Rel File]+getDirectoryFiles x y = liftAction $ traverse (liftIO . parseRelFile) =<< Development.Shake.getDirectoryFiles (toFilePath x) y++-- | Lifted version of `Development.Shake.getDirectoryDirs` using well-typed `Path`s.+getDirectoryDirs :: MonadAction m => Path b Dir -> m [Path Rel Dir]+getDirectoryDirs x = liftAction $ traverse (liftIO . parseRelDir) =<< Development.Shake.getDirectoryDirs (toFilePath x)++-- | Lifted version of `Development.Shake.getDirectoryFilesIO` using well-typed `Path`s.+getDirectoryFilesIO :: MonadIO m => Path b Dir -> [FilePattern] -> m [Path Rel File]+getDirectoryFilesIO x y = liftIO $ traverse (liftIO . parseRelFile) =<< Development.Shake.getDirectoryFilesIO (toFilePath x) y
+ src/Development/Shake/Plus/Env.hs view
@@ -0,0 +1,22 @@+module Development.Shake.Plus.Env (+ getEnv+, getEnvWithDefault+, getEnvError +) where++import Control.Exception.Extra+import qualified Development.Shake+import Development.Shake.Plus+import RIO++-- | Lifted version of `Development.Shake.getEnv`+getEnv :: MonadAction m => String -> m (Maybe String)+getEnv = liftAction . Development.Shake.getEnv++-- | Lifted version of `Development.Shake.getEnvWithDefault`+getEnvWithDefault :: MonadAction m => String -> String -> m String+getEnvWithDefault def var = liftAction $ Development.Shake.getEnvWithDefault def var++-- | Lifted version of `Development.Shake.getEnvError`+getEnvError :: (Partial, MonadAction m) => String -> m String+getEnvError = liftAction . Development.Shake.getEnvError
+ src/Development/Shake/Plus/File.hs view
@@ -0,0 +1,55 @@+module Development.Shake.Plus.File (+ copyFile'+, copyFileChanged+, readFile'+, readFileLines+, writeFile'+, writeFileLines+, writeFileChanged+, removeFiles+, removeFilesAfter+) where++import Control.Exception.Extra+import qualified Development.Shake+import Development.Shake (FilePattern)+import Development.Shake.Plus.Core+import RIO+import qualified RIO.Text as T+import Path++-- | Lifted version of `Development.Shake.copyFile` with well-typed `Path`s.+copyFile' :: (MonadAction m, Partial) => Path Rel File -> Path Rel File -> m ()+copyFile' x y = liftAction $ Development.Shake.copyFile' (toFilePath x) (toFilePath y)++-- | Lifted version of `Development.Shake.copyFileChanged'` with well-typed `Path`s.+copyFileChanged :: (MonadAction m, Partial) => Path Rel File -> Path Rel File -> m ()+copyFileChanged x y = liftAction $ Development.Shake.copyFileChanged (toFilePath x) (toFilePath y)++-- | Lifted version of `Development.Shake.readFile'` with well-typed `Path`.+readFile' :: (MonadAction m, Partial) => Path Rel File -> m Text+readFile' = liftAction . fmap T.pack . Development.Shake.readFile' . toFilePath++-- | Lifted version of `Development.Shake.readFileLines` with well-typed `Path`.+readFileLines :: (MonadAction m, Partial) => Path Rel File -> m [Text]+readFileLines = liftAction . fmap (fmap T.pack) . Development.Shake.readFileLines . toFilePath++-- | Lifted version of `Development.Shake.writeFile` with well-typed `Path`.+writeFile' :: (MonadAction m, Partial) => Path Rel File -> Text -> m ()+writeFile' x y = liftAction $ Development.Shake.writeFile' (toFilePath x) (T.unpack y)++-- | Lifted version of `Development.Shake.writeFileLines` with well-typed `Path`.+writeFileLines :: (MonadAction m, Partial) => Path Rel File -> [Text] -> m ()+writeFileLines x y = liftAction $ Development.Shake.writeFileLines (toFilePath x) (fmap T.unpack y)++-- | Lifted version of `Development.Shake.writeFileChanged` with well-typed `Path`.+writeFileChanged :: (MonadAction m, Partial) => Path b File -> Text -> m ()+writeFileChanged x y = liftAction $ Development.Shake.writeFileChanged (toFilePath x) (T.unpack y)++-- | Lifted version of `Development.Shake.removeFiles` with well-typed `Path`.+removeFiles :: MonadAction m => Path b File -> [FilePattern] -> m ()+removeFiles x y = liftAction . liftIO $ Development.Shake.removeFiles (toFilePath x) y++-- | Lifted version of `Development.Shake.removeFilesAfter` with well-typed `Path`.+removeFilesAfter :: MonadAction m => Path Rel Dir -> [FilePattern] -> m ()+removeFilesAfter x y = liftAction $ Development.Shake.removeFilesAfter (toFilePath x) y
+ src/Development/Shake/Plus/FileRules.hs view
@@ -0,0 +1,29 @@+module Development.Shake.Plus.FileRules (+ need+, (%>)+, (|%>)+, phony+) where++import Control.Exception.Extra+import Development.Shake.Plus.Core+import qualified Development.Shake+import Development.Shake (FilePattern)+import RIO+import Path++-- | Lifted version of `Development.Shake.need` using well-typed `Path`s+need :: (MonadAction m, Partial) => [Path Rel File] -> m ()+need = liftAction . Development.Shake.need . map toFilePath++-- | Lifted version of `Development.Shake.%>` using well-typed `Path`s+(%>) :: (Partial, MonadReader r m, MonadRules m) => FilePattern -> (Path Rel File -> RAction r ()) -> m ()+(%>) x ract = ask >>= \r -> liftRules $ x Development.Shake.%> (runRAction r . (ract <=< parseRelFile))++-- | Lifted version of `Development.Shake.|%>` using well-typed `Path`s+(|%>) :: (Partial, MonadReader r m, MonadRules m) => [FilePattern] -> (Path Rel File -> RAction r ()) -> m ()+(|%>) x ract = ask >>= \r -> liftRules $ x Development.Shake.|%> (runRAction r . (ract <=< parseRelFile))++-- | Lifted version of `Development.Shake.phony` using well-typed `Path`s+phony :: (MonadReader r m, MonadRules m) => String -> RAction r () -> m ()+phony x ract = ask >>= \r -> liftRules $ Development.Shake.phony x $ runRAction r ract
+ src/Development/Shake/Plus/Oracle.hs view
@@ -0,0 +1,40 @@+module Development.Shake.Plus.Oracle (+ addOracle+, addOracleCache+, addOracleHash+, askOracle+, askOracles+) where++import Control.Exception.Extra+import qualified Development.Shake+import Development.Shake (RuleResult, ShakeValue)+import Development.Shake.Plus.Core+import RIO++-- | Lifted version of `Development.Shake.addOracle` using `RAction` runner.+addOracle :: (MonadRules m, MonadReader r m, RuleResult q ~ a, ShakeValue q, ShakeValue a, Partial)+ => (q -> RAction r a)+ -> m (q -> RAction r a)+addOracle ract = ask >>= \r -> liftRules $ (liftAction . ) <$> Development.Shake.addOracle (runRAction r . ract)++-- | Lifted version of `Development.Shake.addOracleCache` using `RAction` runner.+addOracleCache :: (MonadRules m, MonadReader r m, RuleResult q ~ a, ShakeValue q, ShakeValue a, Partial)+ => (q -> RAction r a)+ -> m (q -> RAction r a)+addOracleCache ract = ask >>= \r -> liftRules $ (liftAction . ) <$> Development.Shake.addOracleCache (runRAction r . ract)++-- | Lifted version of `Development.Shake.addOracleHash` using `RAction` runner.+addOracleHash :: (MonadRules m, MonadReader r m, RuleResult q ~ a, ShakeValue q, ShakeValue a, Partial)+ => (q -> RAction r a)+ -> m (q -> RAction r a)+addOracleHash ract = ask >>= \r -> liftRules $ (liftAction . ) <$> Development.Shake.addOracleHash (runRAction r . ract)++-- | Lifted version of `Development.Shake.askOracle`.+askOracle :: (MonadAction m, RuleResult q ~ a, ShakeValue q, ShakeValue a) => q -> m a+askOracle = liftAction . Development.Shake.askOracle++-- | Lifted version of `Development.Shake.askOracles`.+askOracles :: (MonadAction m, RuleResult q ~ a, ShakeValue q, ShakeValue a) => [q]-> m [a]+askOracles = liftAction . Development.Shake.askOracles+
+ src/Development/Shake/Plus/Temp.hs view
@@ -0,0 +1,27 @@+module Development.Shake.Plus.Temp (+ withTempFile+, withTempDir+, withTempFileWithin+, withTempDirWithin+) where++import qualified Development.Shake+import Development.Shake.Plus.Core+import RIO hiding (withTempFile)+import Path++-- | Unlifted version of `Development.Shake.withTempFile` with well-typed `Path`.+withTempFile :: (MonadUnliftAction m, MonadThrow m) => (Path Rel File -> m a) -> m a+withTempFile f = withRunInAction $ \run -> Development.Shake.withTempFile $ run . (f <=< parseRelFile)++-- | Unlifted version of `Development.Shake.withTempFile` with well-typed `Path`.+withTempDir :: (MonadUnliftAction m, MonadThrow m) => (Path Rel Dir -> m a) -> m a+withTempDir f = withRunInAction $ \run -> Development.Shake.withTempDir $ run . (f <=< parseRelDir)++-- | Unlifted version of `Development.Shake.withTempFileWithin` with well-typed `Path`s.+withTempFileWithin :: (MonadUnliftAction m, MonadThrow m) => Path b Dir -> (Path Rel File -> m a) -> m a+withTempFileWithin x f = withRunInAction $ \run -> Development.Shake.withTempFileWithin (toFilePath x) $ run . (f <=< parseRelFile)++-- | Unlifted version of `Development.Shake.withTempDirWithin` with well-typed `Path`s.+withTempDirWithin :: (MonadUnliftAction m, MonadThrow m) => Path b Dir -> (Path Rel Dir -> m a) -> m a+withTempDirWithin x f = withRunInAction $ \run -> Development.Shake.withTempDirWithin (toFilePath x) $ run . (f <=< parseRelDir)