See https://hackage.haskell.org/package/errors-2.2.0/docs/Data-EitherR.html for somewhat related type.

How about `type Result e = Either e ()` ?

2017-06-15 11:38 GMT+02:00 Ivan Lazar Miljenovic <ivan.miljenovic@gmail.com>:
The Maybe type is often (almost always?) used to indicate that a
computation may fail; specifically, `Maybe a` typically indicates that
it may not be possible to always produce a value of type `a`.

However, there are times when the inverse of this is desirable
(usually within a monadic/side-effectful context): if Nothing is
returned then the computation was a success; otherwise, an error
message is returned.  Whilst this usage definitely fits the types, it
breaks the mould of how we think/use Maybe in most cases and may at
times cause confusion.  As such, it may be advisable (and I know I've
done this at least once) to define a `data Result e = Error e |
Success` data type to model this behaviour.

Is this a typical enough requirement that would make it worth adding
such a datatype to base (despite my usual aversion to piling more
things in there) or having a library up on Hackage just for this very
simplistic type?

(Another option would be to use `Either error ()`, which could be
lifted better into an ExceptT result, albeit with the additional
useless parameter/value in there.)

--
Ivan Lazar Miljenovic
Ivan.Miljenovic@gmail.com
http://IvanMiljenovic.wordpress.com
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.