{"action":"created","issue":{"url":"https://api.github.com/repos/ndmitchell/shake/issues/236","labels_url":"https://api.github.com/repos/ndmitchell/shake/issues/236/labels{/name}","comments_url":"https://api.github.com/repos/ndmitchell/shake/issues/236/comments","events_url":"https://api.github.com/repos/ndmitchell/shake/issues/236/events","html_url":"https://github.com/ndmitchell/shake/issues/236","id":69869696,"number":236,"title":"Shake tries to build existing target","user":{"login":"cblp","id":63495,"avatar_url":"https://avatars.githubusercontent.com/u/63495?v=3","gravatar_id":"","url":"https://api.github.com/users/cblp","html_url":"https://github.com/cblp","followers_url":"https://api.github.com/users/cblp/followers","following_url":"https://api.github.com/users/cblp/following{/other_user}","gists_url":"https://api.github.com/users/cblp/gists{/gist_id}","starred_url":"https://api.github.com/users/cblp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cblp/subscriptions","organizations_url":"https://api.github.com/users/cblp/orgs","repos_url":"https://api.github.com/users/cblp/repos","events_url":"https://api.github.com/users/cblp/events{/privacy}","received_events_url":"https://api.github.com/users/cblp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-04-21T14:57:50Z","updated_at":"2015-04-28T21:16:28Z","closed_at":null,"body":"```haskell\r\n{-# LANGUAGE DeriveDataTypeable #-}\r\n\r\nimport Control.Exception  ( Exception, throwIO )\r\nimport Data.Typeable      ( Typeable )\r\nimport Development.Shake  ( (%>), liftIO, shakeArgs, shakeOptions, want )\r\nimport System.Directory   ( doesFileExist )\r\n\r\nmain = shakeArgs shakeOptions $ do\r\n    want [\"a\"]\r\n    \"a\" %> \\_ -> do\r\n        liftIO $ create \"a\"\r\n\r\ndata FileExists = FileExists FilePath\r\n    deriving (Show, Typeable)\r\ninstance Exception FileExists\r\n\r\ncreate :: FilePath -> IO ()\r\ncreate name = do\r\n    exists <- doesFileExist name\r\n    if exists then\r\n        throwIO $ FileExists name\r\n    else\r\n        writeFile name \"\"\r\n```\r\n```\r\n$ ./build.hs\r\nError when running Shake build system:\r\n* a\r\nFileExists \"a\"\r\n```\r\n\r\nHow can I tell Shake that the file already exists and it doesn't need to reset it?"},"comment":{"url":"https://api.github.com/repos/ndmitchell/shake/issues/comments/97209551","html_url":"https://github.com/ndmitchell/shake/issues/236#issuecomment-97209551","issue_url":"https://api.github.com/repos/ndmitchell/shake/issues/236","id":97209551,"user":{"login":"ndmitchell","id":1651197,"avatar_url":"https://avatars.githubusercontent.com/u/1651197?v=3","gravatar_id":"","url":"https://api.github.com/users/ndmitchell","html_url":"https://github.com/ndmitchell","followers_url":"https://api.github.com/users/ndmitchell/followers","following_url":"https://api.github.com/users/ndmitchell/following{/other_user}","gists_url":"https://api.github.com/users/ndmitchell/gists{/gist_id}","starred_url":"https://api.github.com/users/ndmitchell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndmitchell/subscriptions","organizations_url":"https://api.github.com/users/ndmitchell/orgs","repos_url":"https://api.github.com/users/ndmitchell/repos","events_url":"https://api.github.com/users/ndmitchell/events{/privacy}","received_events_url":"https://api.github.com/users/ndmitchell/received_events","type":"User","site_admin":false},"created_at":"2015-04-28T21:16:28Z","updated_at":"2015-04-28T21:16:28Z","body":"You could define a rule that skipped if the file already existed, something like:\r\n\r\n    (???>) pat act = pat %> \\out ->\r\n        b <- doesFileExist out\r\n        unless b $ act out\r\n\r\nBut I think it's unlikely to be common, since you usually want to actually have built the rule with Shake. I view Shake as an alternative to Make in the sense you can build stuff with it, but have explicitly tried to fix the flaws with Make. Since Shake is parameterisable over rule types you can certainly define such a rule (or define a combinator), but I think it has to boil down to `doesFileExist` in the end."}}