Shake+ Extended - Experimental Mechanisms For Shake
This library extends
shake-plus, which enriches
ReaderT and the
Path library. This extended ruleset introduces
within, for better keeping track
of source and output directories, as well as batch loading mechanisms using
One common complaint about Shake is having to keep track of source and output
directories and translating
FilePaths when using the input to an
leading to lots of repetition of the form
(sourceFolder </>) . (-<.> ".ext") . dropDirectory1 which is prone to breakage. Using
Path helps this to some
degree, but in some cases is even more annoying because lots of
MonadThrow, leading to lots of monadic steps inside an
To alleviate this somewhat, we use
Within b (Path Rel File) as a standard
pattern for representing a file within a directory.
Within is a type
available in the within package
that is simply a newtype wrapper over an
Env comonad with the environment
Path b Dir. We provide variants of the file operations and
rules that typically accept or return
Paths or contain callbacks that expect
paths and change these to
Within values. These functions are generally
within. Here is the variant of
getDirectoryFilesWithin' :: MonadAction m => Within Rel [FilePattern] -> m [Within b (Path Rel File)]
You can convert to and from this within-style using
let x = $(mkRelFile "a.txt") `within` $(mkRelDir "foo") -- Within Rel (Path Rel File) fromWithin x -- produces a `Path Rel File`
and you can assert that an existing path lies in a directory by using
asWithin, which throws
if the directory is not a proper prefix of the
$(mkRelFile "foo/a.txt") `asWithin` $(mkRelDir "foo") -- fine $(mkRelFile "a.txt") `asWithin` $(mkRelDir "foo") -- throws error
Filerules such as
(%>) have within-style variants that accept an
(Path b Dir) FilePattern on the left and carry that env to the callback.
(%^>) :: (Partial, MonadReader r m, MonadRules m) => Within Rel FilePattern -> (Within Rel (Path Rel File) -> RAction r ()) -> m ()
You change the underlying filepath with
mapM, whilst you can move
to a new parent directory by using
localDirM which is defined
Within library for when the map between parent directories may throw.
Within library also contains more functions and instances for more
precise changes between output and source directories.
Changelog for shake-plus-extended
- Add `Development.Shake.Plus.Extended.Conduit” with conduit oracle.
LogFuncand a local
Path Rel Dir.
runLoggedShakePlusand add new
- Add a proxy version of
HasLocalOutclass for accessing a lens with a local output directory.
- Add filerules
(/|%>)for implicit rules inside a local directory.
- Initial commit with basic
withinstyle rules and loaders.