{"action":"created","issue":{"url":"https://api.github.com/repos/ndmitchell/shake/issues/318","labels_url":"https://api.github.com/repos/ndmitchell/shake/issues/318/labels{/name}","comments_url":"https://api.github.com/repos/ndmitchell/shake/issues/318/comments","events_url":"https://api.github.com/repos/ndmitchell/shake/issues/318/events","html_url":"https://github.com/ndmitchell/shake/issues/318","id":111076707,"number":318,"title":"Use operational package?","user":{"login":"Mathnerd314","id":322214,"avatar_url":"https://avatars.githubusercontent.com/u/322214?v=3","gravatar_id":"","url":"https://api.github.com/users/Mathnerd314","html_url":"https://github.com/Mathnerd314","followers_url":"https://api.github.com/users/Mathnerd314/followers","following_url":"https://api.github.com/users/Mathnerd314/following{/other_user}","gists_url":"https://api.github.com/users/Mathnerd314/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathnerd314/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathnerd314/subscriptions","organizations_url":"https://api.github.com/users/Mathnerd314/orgs","repos_url":"https://api.github.com/users/Mathnerd314/repos","events_url":"https://api.github.com/users/Mathnerd314/events{/privacy}","received_events_url":"https://api.github.com/users/Mathnerd314/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-10-12T23:57:26Z","updated_at":"2015-10-26T22:04:24Z","closed_at":null,"body":"Rules and Action are contained rather neatly in Core, so they could be replaced with GADT's from the [operational](http://hackage.haskell.org/package/operational-0.2.3.2/docs/Control-Monad-Operational.html) package, e.g.:\r\n```\r\ndata RulesADT a where\r\n  NewResource :: String -> Int -> Rules Resource\r\n  NewThrottle :: String -> Int -> Double -> Rules Resource\r\n  NewCache :: (Eq k, Hashable k) => (k -> Action v) -> Rules (k -> Action v)\r\n  Rule :: Rule key value => (key -> Maybe (Action value)) -> Rules ()\r\n  Action :: Action a -> Rules ()\r\n  Priority :: Double -> Rules () -> Rules ()\r\n  Alternatives :: Rules () -> Rules ()\r\n  WithoutActions :: Rules () -> Rules ()\r\n  RulesIO :: IO a -> Rules a\r\n\r\ntype Rules a = Program RulesADT a\r\n\r\ndata ActionADT a where\r\n    ActionBoom :: Bool -> Action a -> IO b -> Action a\r\n    RunAfter :: IO () -> Action ()\r\n    Apply :: Rule key value => [key] -> Action [value]\r\n    ApplyKeyValue :: [Key] -> Action [Value]\r\n    GetShakeOptions :: Action ShakeOptions\r\n    GetProgress :: Action Progress\r\n    Traced :: String -> IO a -> Action a\r\n    PutWhen :: Verbosity -> String -> Action ()\r\n    GetVerbosity :: Action Verbosity\r\n    WithVerbosity :: Verbosity -> Action a -> Action a\r\n    TrackUse :: ShakeValue key => key -> Action ()\r\n    TrackCheckUsed :: Action ()\r\n    TrackChange :: ShakeValue key => key -> Action ()\r\n    TrackAllow :: ShakeValue key => (key -> Bool) -> Action ()\r\n    BlockApply :: String -> Action a -> Action a\r\n    WithResource :: Resource -> Int -> Action a -> Action a\r\n    WithResources :: [(Resource, Int)] -> Action a -> Action a\r\n    UnsafeExtraThread :: Action a -> Action a\r\n    UnsafeIgnoreDependencies :: Action a -> Action a\r\n    LiftIO :: IO a -> Action a\r\n\r\ntype Action a = Program ActionADT a\r\n```\r\nBesides being more pure, this approach would allow batching up Apply operations so that ``need [\"a\", \"b\"]`` and ``need [\"a\"] >> need [\"b\"]`` can be equally parallel.\r\n\r\nI'm not sure how to handle the MonadFix instance for Rules (#270), so maybe this only makes sense for Action."},"comment":{"url":"https://api.github.com/repos/ndmitchell/shake/issues/comments/151297503","html_url":"https://github.com/ndmitchell/shake/issues/318#issuecomment-151297503","issue_url":"https://api.github.com/repos/ndmitchell/shake/issues/318","id":151297503,"user":{"login":"Mathnerd314","id":322214,"avatar_url":"https://avatars.githubusercontent.com/u/322214?v=3","gravatar_id":"","url":"https://api.github.com/users/Mathnerd314","html_url":"https://github.com/Mathnerd314","followers_url":"https://api.github.com/users/Mathnerd314/followers","following_url":"https://api.github.com/users/Mathnerd314/following{/other_user}","gists_url":"https://api.github.com/users/Mathnerd314/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathnerd314/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathnerd314/subscriptions","organizations_url":"https://api.github.com/users/Mathnerd314/orgs","repos_url":"https://api.github.com/users/Mathnerd314/repos","events_url":"https://api.github.com/users/Mathnerd314/events{/privacy}","received_events_url":"https://api.github.com/users/Mathnerd314/received_events","type":"User","site_admin":false},"created_at":"2015-10-26T22:04:24Z","updated_at":"2015-10-26T22:04:24Z","body":"Interesting. If it is supposed to work, then there's a bug in ``-B``:\r\n```\r\n$ touch a.png.in && runhaskell Main.hs x.pdf\r\n# cp (for a.png)\r\n# sort (for x.pdf)\r\n$ touch a.png.in && runhaskell Main.hs -B x.pdf\r\n# sort (for x.pdf)\r\n# cp (for a.png)\r\n```"}}