Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add withTmpFile? #134

Open
kaizhang opened this issue Dec 6, 2016 · 1 comment
Open

Add withTmpFile? #134

kaizhang opened this issue Dec 6, 2016 · 1 comment

Comments

@kaizhang
Copy link

kaizhang commented Dec 6, 2016

  1. Shelly doesn't have withTmpFile, which is a very useful function.
  2. withTmpDir should be able to create tmp dir under a specific location, like mktempdir does in Turtle.

Any particular reason for not having these?

@andreasabel
Copy link
Collaborator

There is https://hackage.haskell.org/package/temporary-1.3/docs/System-IO-Temp.html#v:withTempFile

withTempFile :: (MonadIO m, MonadMask m) =>
                FilePath -- ^ Parent directory to create the file in
             -> String   -- ^ File name template
             -> (FilePath -> Handle -> m a) -- ^ Callback that can use the file
             -> m a

This requires a MonadMask Sh instance which we might not have: https://hackage.haskell.org/package/exceptions-0.10.0/docs/Control-Monad-Catch.html#t:MonadMask

A similar function is in https://hackage.haskell.org/package/unliftio-0.2.23.0/docs/UnliftIO-Temporary.html#v:withTempFile which requires instance MonadUnliftIO Sh.

Maybe it is possible to define one of these instances for Sh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants