[Haskell-cafe] testing for exceptions

Darren Grant dedgrant at gmail.com
Sat Oct 31 11:04:42 UTC 2015


I'd expect most Haskellers to recommend something like,

  f2 :: Integer -> Either Integer ErrorString

where ErrorString is some specific error value type. (String may suffice
for you.)

This is a safe general solution, but there are many potentially more
specific possibilities that might make your program simpler depending on
how this function relates to the context it will be used in.

Cheers,
Darren
On Oct 31, 2015 21:46, "Roelof Wobben" <r.wobben at home.nl> wrote:

> Op 31-10-2015 om 11:40 schreef Darren Grant:
>
>>
>> Unfrotunately the answer to this is not simple:
>>
>>
>> http://stackoverflow.com/questions/4243117/how-to-catch-and-ignore-a-call-to-the-error-function
>>
>> 'error' more or less terminates the program in an unreasonable way.
>>
>> It would be preferable for f2 to result in a type that can contain the
>> error result to be parsed.
>>
>> Cheers,
>> Darren
>>
>>
>>
>
> Oke,
>
> So I have to change the type of f2.
>
> To what do I have to change it to make it testable.
>
> Roelof
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151031/7b447d52/attachment.html>


More information about the Haskell-Cafe mailing list