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.
Either doesn't have to be "stringly typed" per se thanks to sum types. You can write a type like:
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.