[Haskell-beginners] What is this?
David McBride
toad3k at gmail.com
Wed Nov 13 19:20:12 UTC 2019
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 at 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 at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20191113/67348072/attachment.html>
More information about the Beginners
mailing list