
Hello, Can anyone shed a light on the proper way to write the function below. It looks pretty standard, but it's not clear to me what it is? data Abortable res = Aborted | Executed res deriving Functor -- i.e. Maybe abortableThroughEither :: Abortable (Either a b) -> Either a (Abortable b) abortableThroughEither Aborted = Right Aborted abortableThroughEither (Executed (Left a)) = Left a abortableThroughEither (Executed (Right b)) = Right (Executed b) Thanks! Dimitri -- 2E45 D376 A744 C671 5100 A261 210B 8461 0FB0 CA1F

It converts from Abortable (Either a b) to Either a (Abortable b). My guess at their probable intent was that this operation tends to error without aborting more often than it errors from an abort, so they put the error on the outside so they can check the common case more easily. On Wed, Nov 13, 2019 at 2:04 PM Dimitri DeFigueiredo < defigueiredo@ucdavis.edu> wrote:
Hello,
Can anyone shed a light on the proper way to write the function below. It looks pretty standard, but it's not clear to me what it is?
data Abortable res = Aborted | Executed res deriving Functor -- i.e. Maybe
abortableThroughEither :: Abortable (Either a b) -> Either a (Abortable b) abortableThroughEither Aborted = Right Aborted abortableThroughEither (Executed (Left a)) = Left a abortableThroughEither (Executed (Right b)) = Right (Executed b)
Thanks!
Dimitri
-- 2E45 D376 A744 C671 5100 A261 210B 8461 0FB0 CA1F
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

Incidentally, if you also derive Foldable and Traversable for Aborted,
abortableThroughEither is simply sequence.
On Wed, Nov 13, 2019 at 11:20 AM David McBride
It converts from Abortable (Either a b) to Either a (Abortable b).
My guess at their probable intent was that this operation tends to error without aborting more often than it errors from an abort, so they put the error on the outside so they can check the common case more easily.
On Wed, Nov 13, 2019 at 2:04 PM Dimitri DeFigueiredo < defigueiredo@ucdavis.edu> wrote:
Hello,
Can anyone shed a light on the proper way to write the function below. It looks pretty standard, but it's not clear to me what it is?
data Abortable res = Aborted | Executed res deriving Functor -- i.e. Maybe
abortableThroughEither :: Abortable (Either a b) -> Either a (Abortable b) abortableThroughEither Aborted = Right Aborted abortableThroughEither (Executed (Left a)) = Left a abortableThroughEither (Executed (Right b)) = Right (Executed b)
Thanks!
Dimitri
-- 2E45 D376 A744 C671 5100 A261 210B 8461 0FB0 CA1F
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (3)
-
Akhra Lief Gannon
-
David McBride
-
Dimitri DeFigueiredo