News for hackers. Stuff that matters.
Re:Another go at the Next Big Language by tkahn6 on Monday September 03, 2012 @01:25AM (#4469207)
Good writeup. Haskell actually does have an Error type class and ErrorT monad transformer for more fine-grained error handling.

Maybe gives you binary error handling, it either fails (Nothing) or succeeds (Just).

Either gives you "stringly-typed" errors which is sometimes a good choice.

http://hackage.haskell.org/packages/archive/mtl/1.1.0.2/doc/...

Re:Another go at the Next Big Language by tikhonj on Monday September 03, 2012 @02:03AM (#4469274)
ErrorT is similar to EitherT, so I just used the latter to make the names less confusing.

Either doesn't have to be "stringly typed" per se thanks to sum types. You can write a type like:

    data ErrorType = SomeError
                   | OtherError String
                   | ...
The compiler can now check that you handle all possible errors and will give you a warning if you don't, so it's strictly better than using strings.

Coincidentally, this is one place where some sort of sub-typing would be nice, I think. This sort of type would be perfect using OCaml's polymorphic variants because then you could share different error cases around while specifying a very specific type for each computation.