module Development.Shake.Plus.FileRules (
need
, want
, needP
, wantP
, needIn
, wantIn
, needWithin
, wantWithin
, needWithin'
, wantWithin'
, (%>)
, (|%>)
, (%^>)
, (|%^>)
, phony
) where
import Control.Comonad.Env as E
import Control.Exception.Extra
import qualified Development.Shake
import qualified Development.Shake.FilePath
import Development.Shake.Plus.Core
import Path
import RIO as R
import Within
need :: (Partial, MonadAction m, Foldable t) => t String -> m ()
need = liftAction . Development.Shake.need . toList
want :: (Partial, MonadRules m, Foldable t) => t String -> m ()
want = liftRules . Development.Shake.want . toList
needP :: (Partial, MonadAction m, Traversable t) => t (Path b File) -> m ()
needP = need . fmap toFilePath
wantP :: (Partial, MonadRules m, Traversable t) => t (Path b File) -> m ()
wantP = want . fmap toFilePath
needIn :: (Partial, MonadAction m, Traversable t) => Path b Dir -> t (Path Rel File) -> m ()
needIn x = needP . fmap (x </>)
wantIn :: (Partial, MonadRules m, Traversable t) => Path b Dir -> t (Path Rel File) -> m ()
wantIn x = wantP . fmap (x </>)
needWithin :: (Partial, MonadAction m, Traversable t) => Within b (t (Path Rel File)) -> m ()
needWithin x = needIn (E.ask x) (extract x)
wantWithin :: (Partial, MonadRules m, Traversable t) => Within b (t (Path Rel File)) -> m ()
wantWithin x = wantIn (E.ask x) (extract x)
needWithin' :: (Partial, MonadAction m, Traversable t) => t (Within b (Path Rel File)) -> m ()
needWithin' x = needP $ fromWithin <$> x
wantWithin' :: (Partial, MonadRules m, Traversable t) => t (Within b (Path Rel File)) -> m ()
wantWithin' x = wantP $ fromWithin <$> x
(%>) :: (Partial, MonadReader r m, MonadRules m) => FilePattern -> (Path Rel File -> RAction r ()) -> m ()
(%>) x ract = R.ask >>= \r -> liftRules $ x Development.Shake.%> (runRAction r . (ract <=< parseRelFile))
(|%>) :: (Partial, MonadReader r m, MonadRules m) => [FilePattern] -> (Path Rel File -> RAction r ()) -> m ()
(|%>) x ract = R.ask >>= \r -> liftRules $ x Development.Shake.|%> (runRAction r . (ract <=< parseRelFile))
(%^>) :: (Partial, MonadReader r m, MonadRules m) => Within Rel FilePattern -> (Within Rel (Path Rel File) -> RAction r ()) -> m ()
(%^>) xs ract = liftA2 (Development.Shake.FilePath.</>) (toFilePath . E.ask) extract xs %> (ract <=< (`asWithin` E.ask xs))
(|%^>) :: (Partial, MonadReader r m, MonadRules m) => Within Rel [FilePattern] -> (Within Rel (Path Rel File) -> RAction r ()) -> m ()
(|%^>) xs ract = ((Development.Shake.FilePath.</>) (toFilePath . E.ask $ xs) <$> extract xs) |%> (ract <=< (`asWithin` E.ask xs))
phony :: (MonadReader r m, MonadRules m) => String -> RAction r () -> m ()
phony x ract = R.ask >>= \r -> liftRules $ Development.Shake.phony x $ runRAction r ract