module Shakebook.Rules where
import Control.Comonad.Cofree
import Control.Comonad.Store
import Development.Shake
import RIO
comonadStoreRuleGen :: ComonadStore s w
=> FilePattern
-> (FilePattern -> s)
-> (FilePattern -> a)
-> (a -> Action (w b))
-> (b -> FilePath -> Action ())
-> Rules ()
comonadStoreRuleGen fp f g h k =
fp %> \x -> do
xs <- h (g x)
k (extract (seek (f x) xs)) x
cofreeRuleGen :: (Traversable w, ComonadCofree f w)
=> w FilePath
-> (FilePath -> FilePath)
-> (w FilePath -> FilePath -> Action ())
-> Rules ()
cofreeRuleGen xs h k = do
let f ys = h (extract ys) %> k ys
void . sequence . extend f $ xs