[Haskell-beginners] Monad for Pair

Kim-Ee Yeoh ky3 at atamo.com
Wed Nov 18 07:44:56 UTC 2015


On Wed, Nov 18, 2015 at 5:15 AM, Marcin Mrotek <marcin.jan.mrotek at gmail.com>
wrote:

The first law could work if >>= just chose one of the values
> arbitrarily. But the second law is a hopeless case. You would need to
> pick one element of a pair, plug it into a function that repeats the
> argument, and somehow get back the other element that you've already
> dropped.
>
> Concluding, either I'm sorely mistaken or there indeed isn't a Monad
> instance for Pair.
>

Not quite sorely mistaken but there is a glitch in the logic of what you
wrote when you returned from join to bind.

You might want to try writing out a test instance in full and re-checking
the second law.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151118/a9d829fb/attachment.html>


More information about the Beginners mailing list