[Haskell-cafe] ANNOUNCE: AbortT-transformers version 1.0

Gregory Crosswhite gcross at phys.washington.edu
Wed Sep 8 17:09:12 EDT 2010


 On 09/08/10 12:54, Henning Thielemann wrote:
> Gregory Crosswhite schrieb:
>>  For whatever reason, nobody seems to have gotten around to implementing
>> an Abort monad transformer (outside the monadLib package), so I decided
>> to write one myself since I wanted the functionality but I use
>> "transformers" rather than "monadLib".
> Is AbortT different from ErrorT, ExceptionalT and friends?
Yes, for a couple of reasons.  First, computations in the AbortT monad
always "succeed";  they just might succeed earlier than expected.  This
contrasts with the computations in the ErrorT, etc. monads where
aborting earlier is a signal that an error has occurred.  Second, AbortT
is not isomorphic to ErrorT because ErrorT requires that terminating
early returns not just any value but a value which is an instance of
Error;  furthermore, even if this were not a problem, it would be a
problem that pattern match failures would have the effect of stuffing a
string into your value that you probably didn't want and returning it
early as if it were the correct answer.

ExceptionT is a different matter because it handles "fail" as an
uncaught error and places no restrictions on the error type, so one
could implement the same functionality as AbortT by using ExceptionalT
and requiring the end result be a monadic value of type "ExceptionalT e
m e", where the exception and result types are the same.  However, I
believe that it is better to have the AbortT functionality available as
a separate simple library specialized for this purpose than to have its
functionality buried inside a more general library that is really
intended to be used for a different purpose.

Cheers,
Greg



More information about the Haskell-Cafe mailing list