[Haskell-beginners] exception, not in IO
k.bleijenberg at lijbrandt.nl
Sun Jul 14 20:07:08 CEST 2013
You can turn anything into an IO action with return, or you could catch the exception at a level where you are performing IO. Would this be what you're after?
Wait until you perform IO, seems quit uneasy to me and why? Converting a string to a typeable is not a IO action. Problem is that this function lives in a dll. The IO is done by the calling program (not a Haskell program). The function is not in a monad, it is a pure function. So I think I can’t do a return.
On Sun, Jul 14, 2013 at 7:47 PM, Kees Bleijenberg <k.bleijenberg at lijbrandt.nl> wrote:
The app I’am working on, converts a jsonString to another string encoding.
The function I want to write is jsonString -> (encoding, errorMsg) so String-> (String, String)
For this purpose I have a typeable datastructure Glass. Because it is typeable I can do (decodeJSON jsonString) :: Glass
But sometimes the jsonString is not valid (misformed or wrong fields). decodeJSON then throws a exception. I want to
catch that exection and transform the result to something like (“” , theErrorMsg). Unfortunately all catch functions want IO parameters.
What can I do?
Beginners mailing list
Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners