Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-22 Thread Eric Rasmussen
Thanks John. I'll try it out, along with Kmett's exceptions package I just found: http://hackage.haskell.org/packages/archive/exceptions/0.1.1/doc/html/Control-Monad-Catch.html I noticed on an issue for lens (https://github.com/ekmett/lens/issues/301) they switched to this since MonadCatchIO is

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-22 Thread John Lato
I don't think there's anything necessarily wrong with ekmett's exceptions package, but you should be aware that it may not do what you expect: module Foo where import Control.Monad.IO.Class import Control.Monad.Catch import Control.Exception (ArithException) f :: CatchT IO String f = catch

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-21 Thread Arie Peterson
On Thursday 18 July 2013 23:05:33 Eric Rasmussen wrote: […] Would there be any interest in cleaning that up and adding it (or something similar) to Control.Monad.CatchIO? […] MonadCatchIO-transformers is being deprecated, as recently GHC has removed the 'block' and 'unblock' functions,

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-21 Thread Eric Rasmussen
Arie, Thanks for calling that out. The most useful part for my case is the MonadCatchIO implementation of catch: catch :: Exception e = m a - (e - m a) - m a Hoogle shows a few similar functions for that type signature, but they won't work for the case of catching an IOException in an arbitrary

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-21 Thread John Lato
I think most people use monad-control these days for catching exceptions in monad stacks (http://hackage.haskell.org/package/monad-control-0.3.2.1). The very convenient lifted-base package ( http://hackage.haskell.org/package/lifted-base) depends on it and exports a function

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-19 Thread Eric Rasmussen
://hackage.haskell.org/package/MonadCatchIO-transformers 2013/7/18 Eric Rasmussen ericrasmus...@gmail.com Hello, I am writing a small application that uses a monad transformer stack, and I'm looking for advice on the best way to handle IO errors. Ideally I'd like to be able to perform an action

[Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-18 Thread Eric Rasmussen
Hello, I am writing a small application that uses a monad transformer stack, and I'm looking for advice on the best way to handle IO errors. Ideally I'd like to be able to perform an action (such as readFile file_that_does_not_exist), catch the IOError, and then convert it to a string error

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-18 Thread Alberto G. Corona
to handle IO errors. Ideally I'd like to be able to perform an action (such as readFile file_that_does_not_exist), catch the IOError, and then convert it to a string error in MonadError. Here's an example of what I'm doing now: {-# LANGUAGE FlexibleContexts #-} import Control.Monad.Error import

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-18 Thread David Sorokin
way to handle IO errors. Ideally I'd like to be able to perform an action (such as readFile file_that_does_not_exist), catch the IOError, and then convert it to a string error in MonadError. Here's an example of what I'm doing now: {-# LANGUAGE FlexibleContexts #-} import

RE: IO errors

2001-11-29 Thread Simon Marlow
A quick look at the source looks like both GHC and NHC will simply pass on errors from the OS, so for example with module Main where import IO import Directory main :: IO() main = do catch (createDirectory this/does/not/exist/foo) (\e -

RE: IO errors

2001-11-29 Thread Simon Peyton-Jones
| Two possibilities: either createDirectory should act like | 'mkdir -p' and make the whole path, or the library report | should document isDoesNotExistError as a possible error | thrown by createDirectory. I'd vote for the latter. I'm willing to do that for H98 unless anyone can think of a

IO errors

2001-11-28 Thread Ian Lynagh
Hi guys, Me again I'm afraid... A quick look at the source looks like both GHC and NHC will simply pass on errors from the OS, so for example with module Main where import IO import Directory main :: IO() main = do catch (createDirectory this/does/not/exist/foo)

IO Errors

2001-05-25 Thread Steinitz, Dominic J
Can anyone tell me why this behaves as it does? In Hugs, I get C:\My Documents\functional\ldapsck1\buffer.hs Main main Illegal operation (561 reductions, 1029 cells) Main If the input file is the one line: 1234567812345678 the output file is: Starting logging 1234567812345678 Error In

RE: IO Errors

2001-05-25 Thread Steinitz, Dominic J
13:03:00 To: Dominic Steinitz haskell cc: bcc: Subject:RE: IO Errors In ghc, the program hangs without even creating a file. With GHC 5.00.1 here it creates the output file containing: Starting logging 1234567812345678 Finishing logging which GHC version was hanging for you