I would like to use the temporary
package with Shake, but that requires Action
to have an instance for MonadMask
, which is missing. Why does Shake not provide such an instance?
Asked
Active
Viewed 137 times
2

Neil Mitchell
- 9,090
- 1
- 27
- 85
-
https://github.com/ndmitchell/shake/issues/186 – Cactus Aug 21 '15 at 04:05
1 Answers
5
There are two reasons:
- It's impossible, since
Action
is based on a continuation monad, and you can't implementMonadMask
for a continuation monad. See this blog post for a rough justification of why that is impossible. - It's undesirable, since then you could make choices depending on whether a dependent rule succeeds or fails, whereas in Shake the failure of a rule you depend on should always result in you failing.
However, Shake does provide actionFinally
and actionOnException
as building blocks, which are a restricted variant of the functions available in MonadMask
. In addition, Shake provides withTempFile
and withTempDir
, which do some of the same things as the temporary
package. And finally, if you are entirely in IO
, then liftIO
and bracket
works fine.

Neil Mitchell
- 9,090
- 1
- 27
- 85