packages feed

shake-plus 0.1.0.2 → 0.1.1.0

raw patch · 5 files changed

+66/−36 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Development.Shake.Plus.FileRules: needWithin :: (Partial, MonadAction m, Traversable t) => Within b (t (Path Rel File)) -> m ()
+ Development.Shake.Plus.FileRules: needWithin' :: (Partial, MonadAction m, Traversable t) => t (Within b (Path Rel File)) -> m ()
+ Development.Shake.Plus.FileRules: wantWithin :: (Partial, MonadRules m, Traversable t) => Within b (t (Path Rel File)) -> m ()
+ Development.Shake.Plus.FileRules: wantWithin' :: (Partial, MonadRules m, Traversable t) => t (Within b (Path Rel File)) -> m ()
- Development.Shake.Plus.Directory: getDirectoryFilesWithin :: MonadAction m => Path b Dir -> [FilePattern] -> m (Within b [Path Rel File])
+ Development.Shake.Plus.Directory: getDirectoryFilesWithin :: MonadAction m => Within b [FilePattern] -> m (Within b [Path Rel File])
- Development.Shake.Plus.Directory: getDirectoryFilesWithin' :: MonadAction m => Path b Dir -> [FilePattern] -> m [Within b (Path Rel File)]
+ Development.Shake.Plus.Directory: getDirectoryFilesWithin' :: MonadAction m => Within b [FilePattern] -> m [Within b (Path Rel File)]
- Development.Shake.Plus.FileRules: need :: (Partial, MonadAction m) => [String] -> m ()
+ Development.Shake.Plus.FileRules: need :: (Partial, MonadAction m, Foldable t) => t String -> m ()
- Development.Shake.Plus.FileRules: needIn :: (Partial, MonadAction m) => Path Rel Dir -> [Path Rel File] -> m ()
+ Development.Shake.Plus.FileRules: needIn :: (Partial, MonadAction m, Traversable t) => Path b Dir -> t (Path Rel File) -> m ()
- Development.Shake.Plus.FileRules: needP :: (Partial, MonadAction m) => [Path Rel File] -> m ()
+ Development.Shake.Plus.FileRules: needP :: (Partial, MonadAction m, Traversable t) => t (Path b File) -> m ()
- Development.Shake.Plus.FileRules: want :: (Partial, MonadRules m) => [String] -> m ()
+ Development.Shake.Plus.FileRules: want :: (Partial, MonadRules m, Foldable t) => t String -> m ()
- Development.Shake.Plus.FileRules: wantIn :: (Partial, MonadRules m) => Path Rel Dir -> [Path Rel File] -> m ()
+ Development.Shake.Plus.FileRules: wantIn :: (Partial, MonadRules m, Traversable t) => Path b Dir -> t (Path Rel File) -> m ()
- Development.Shake.Plus.FileRules: wantP :: (Partial, MonadRules m) => [Path Rel File] -> m ()
+ Development.Shake.Plus.FileRules: wantP :: (Partial, MonadRules m, Traversable t) => t (Path b File) -> m ()
- Development.Shake.Plus.Loaders: batchLoadWithin :: MonadAction m => Path b Dir -> [FilePattern] -> (Path b File -> m a) -> m (Within b (HashMap (Path Rel File) a))
+ Development.Shake.Plus.Loaders: batchLoadWithin :: MonadAction m => Within b [FilePattern] -> (Within b (Path Rel File) -> m a) -> m (Within b (HashMap (Path Rel File) a))
- Development.Shake.Plus.Loaders: batchLoadWithin' :: MonadAction m => Path b Dir -> [FilePattern] -> (Path b File -> m a) -> m (HashMap (Within b (Path Rel File)) a)
+ Development.Shake.Plus.Loaders: batchLoadWithin' :: MonadAction m => Within b [FilePattern] -> (Within b (Path Rel File) -> m a) -> m (HashMap (Within b (Path Rel File)) a)

Files

ChangeLog.md view
@@ -1,5 +1,12 @@ # Changelog for shake-plus +## v0.1.1.0++* Make `Within` style functions more consistent in that they actually take `Within` values+  across the board.+* Make `batchLoad` functions more consistent and usable.+* `need` and `want` variants now take any `Traversable`.+ ## v0.1.0.0  * Update to `within-0.1.1.0` which changes the data type to an `Env` comonad.
shake-plus.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 6d6d5c75e5be3568e6aadea114b64040db56d0be6b6b9bb008345a5b8ee71776+-- hash: f808d169ff8bcc1ebeb21d2907855a6fb0f592026d7a94b1e42630ac6199a522  name:           shake-plus-version:        0.1.0.2+version:        0.1.1.0 synopsis:       Re-export of Shake using well-typed paths and ReaderT. description:    Re-export of Shake using well-typed paths and ReaderT. You can thread logging through your Shake Actions, and better keep track of source and output folders using the Within type. category:       development, shake
src/Development/Shake/Plus/Directory.hs view
@@ -8,6 +8,7 @@ , getDirectoryFilesIO ) where +import           Control.Comonad.Env as E import qualified Development.Shake import           Development.Shake.Plus.Core import           Path@@ -26,17 +27,17 @@ getDirectoryFiles :: MonadAction m => Path b Dir -> [FilePattern] -> m [Path Rel File] getDirectoryFiles x y = liftAction $ traverse (liftIO . parseRelFile) =<< Development.Shake.getDirectoryFiles (toFilePath x) y --- | Like `getDirectoryFiles`, but returns a `Within` contaning a list of `Path`s.-getDirectoryFilesWithin :: MonadAction m => Path b Dir -> [FilePattern] -> m (Within b [Path Rel File])-getDirectoryFilesWithin x pat = do-  xs <- getDirectoryFiles x pat-  return (xs `within` x)+-- | Like `getDirectoryFiles`, but accepts a `Within` value and returns a `Within` contaning a list of `Path`s+getDirectoryFilesWithin :: MonadAction m => Within b [FilePattern] -> m (Within b [Path Rel File])+getDirectoryFilesWithin x = do+  xs <- getDirectoryFiles (E.ask x) (extract x)+  return (xs <$ x)  -- | Like `getDirectoryFilesWithin`, but returns a list of `Within` values instead of a `Within`` of a list.-getDirectoryFilesWithin' :: MonadAction m => Path b Dir -> [FilePattern] -> m [Within b (Path Rel File)]-getDirectoryFilesWithin' x pat = do-  xs <- getDirectoryFiles x pat-  return ((`within` x) <$> xs)+getDirectoryFilesWithin' :: MonadAction m => Within b [FilePattern] -> m [Within b (Path Rel File)]+getDirectoryFilesWithin' x = do+  xs <- getDirectoryFiles (E.ask x) (extract x)+  return ((<$ x) <$> xs)  -- | Lifted version of `Development.Shake.getDirectoryDirs` using well-typed `Path`s. getDirectoryDirs :: MonadAction m => Path b Dir -> m [Path Rel Dir]
src/Development/Shake/Plus/FileRules.hs view
@@ -5,6 +5,10 @@ , wantP , needIn , wantIn+, needWithin+, wantWithin+, needWithin'+, wantWithin' , (%>) , (|%>) , (%^>)@@ -24,30 +28,46 @@ -- | Lifted version of `Development.Shake.need`, This still uses `String`s -- because it may refer to a phony rule. For the `Path` specific version -- use `needP`-need :: (Partial, MonadAction m) => [String] -> m ()-need = liftAction . Development.Shake.need+need :: (Partial, MonadAction m, Foldable t) => t String -> m ()+need = liftAction . Development.Shake.need . toList  -- | Lifted version of `Development.Shake.want`. This still uses `String`s -- because it may refer to a phony rule. For the `Path` specific version -- use wantP.-want :: (Partial, MonadRules m) => [String] -> m ()-want = liftRules . Development.Shake.want+want :: (Partial, MonadRules m, Foldable t) => t String -> m ()+want = liftRules . Development.Shake.want . toList  -- | Lifted version of `Development.Shake.need` using well-typed `Path`s-needP :: (Partial, MonadAction m) => [Path Rel File] -> m ()-needP = need . map toFilePath+needP :: (Partial, MonadAction m, Traversable t) => t (Path b File) -> m ()+needP = need . fmap toFilePath  -- | Lifted version of `Development.Shake.want` using well-typed `Path`s-wantP :: (Partial, MonadRules m) => [Path Rel File] -> m ()-wantP = want . map toFilePath+wantP :: (Partial, MonadRules m, Traversable t) => t (Path b File) -> m ()+wantP = want . fmap toFilePath  -- | Like `needP`, but accepts `Path`s relative to the first argument.-needIn :: (Partial, MonadAction m) => Path Rel Dir -> [Path Rel File] -> m ()+needIn :: (Partial, MonadAction m, Traversable t) => Path b Dir -> t (Path Rel File) -> m () needIn x = needP . fmap (x </>)  -- | Like `wantP`, but accepts `Path`s relative to the first argument.-wantIn :: (Partial, MonadRules m) => Path Rel Dir -> [Path Rel File] -> m ()+wantIn :: (Partial, MonadRules m, Traversable t) => Path b Dir -> t (Path Rel File) -> m () wantIn x = wantP . fmap (x </>)++-- | Like `needIn`, but accepts a list of `Path`s inside a `Within` value.+needWithin :: (Partial, MonadAction m, Traversable t) => Within b (t (Path Rel File)) -> m ()+needWithin x = needIn (E.ask x) (extract x)++-- | Like `wantIn`, but accepts a list of `Path`s insides a `Within` value.+wantWithin :: (Partial, MonadRules m, Traversable t) => Within b (t (Path Rel File)) -> m ()+wantWithin x = wantIn (E.ask x) (extract x)++-- | Like `needWithin`, but accepts a list of `Within`s instead of a `Within` of a list.+needWithin' :: (Partial, MonadAction m, Traversable t) => t (Within b (Path Rel File)) -> m ()+needWithin' x = needP $ fromWithin <$> x++-- | Like `wantWithin`, but accepts a list of `Within`s instead of a `Within` of a list.+wantWithin' :: (Partial, MonadRules m, Traversable t) => t (Within b (Path Rel File)) -> m ()+wantWithin' x = wantP $ fromWithin <$> x  -- | Lifted version of `Development.Shake.%>` using well-typed `Path`s (%>) :: (Partial, MonadReader r m, MonadRules m) => FilePattern -> (Path Rel File -> RAction r ()) -> m ()
src/Development/Shake/Plus/Loaders.hs view
@@ -4,6 +4,7 @@ , batchLoadWithin' ) where +import           Control.Comonad.Env as E import           Development.Shake.Plus.Core import           Development.Shake.Plus.Directory import           Path@@ -19,28 +20,29 @@ batchLoad :: MonadAction m           => Path b Dir -- ^ The directory to search in           -> [FilePattern] -- ^ A filepattern to match against.-          -> (Path b File -> m a) -- ^ A `Development.Shake.newCache` operation that loads the file and turns it into some `a`.+          -> (Path b File -> m a) -- ^ A `Development.Shake.Plus.newCache` operation that loads the file and turns it into some `a`.           -> m (HashMap (Path Rel File) a) batchLoad dir pat f = do-  xs <- getDirectoryFiles dir pat >>= mapM (traverseToSnd $ f . fromWithin . (`within` dir))-  return . HM.fromList $ xs+  xs  <- getDirectoryFiles dir pat+  xs' <- mapM (traverseToSnd $ f . (dir </>)) xs+  return . HM.fromList $ xs'  -- | Like `batchLoad`, but returns an `Within` of a `Dir` containing the `HashMap` batchLoadWithin :: MonadAction m-                => Path b Dir -- ^ The directory to search in-                -> [FilePattern] -- ^ A filepattern to match against.-                -> (Path b File -> m a) -- ^ A `Development.Shake.newCache` operation that loads the file and turns it into some `a`.+                => Within b [FilePattern] -- ^ The directory and filepattern to search.+                -> (Within b (Path Rel File) -> m a) -- ^ A `Development.Shake.Plus.newCache` operation that loads the file and turns it into some `a`.                 -> m (Within b (HashMap (Path Rel File) a))-batchLoadWithin dir pat f = do-  xs <- getDirectoryFiles dir pat >>= mapM (traverseToSnd $ f . fromWithin . (`within` dir))-  return $ (`within` dir) $ HM.fromList xs+batchLoadWithin w f = do+  xs  <- getDirectoryFiles (E.ask w) (extract w)+  xs' <- mapM (traverseToSnd $ f . (`within` E.ask w)) xs+  return $ (`within` E.ask w) $ HM.fromList xs'  -- | Like `batchLoadWithin'`, but returns a `HashMap` containing `Within` values instead of an `Within` of a `Hashmap`. batchLoadWithin' :: MonadAction m-                 => Path b Dir -- ^ The directory to search in-                 -> [FilePattern] -- ^ A filepattern to match against.-                 -> (Path b File -> m a) -- ^ A `Development.Shake.newCache` operation that loads the file and turns it into some `a`.+                 => Within b [FilePattern] -- ^ The directory and filepattern to search.+                 -> (Within b (Path Rel File) -> m a) -- ^ A `Development.Shake.Plus.newCache` operation that loads the file and turns it into some `a`.                  -> m (HashMap (Within b (Path Rel File)) a)-batchLoadWithin' dir pat f = do-  xs <- getDirectoryFiles dir pat >>= mapM (traverseToSnd $ f . fromWithin . (`within` dir))-  return $ HM.fromList (first (`within` dir) <$> xs)+batchLoadWithin' w f = do+  xs  <- getDirectoryFiles (E.ask w) (extract w)+  xs' <- mapM (traverseToSnd $ f . (`within` E.ask w)) xs+  return $ HM.fromList (first (`within` E.ask w) <$> xs')