[Haskell-cafe] instance Monoid a => Monad ((,) a)

Ben Franksen ben.franksen at online.de
Sat Aug 3 08:57:14 UTC 2019


Am 03.08.19 um 01:48 schrieb Neil Mayhew:
> On 2019-08-02 5:38 p.m., Benjamin Franksen wrote:
> 
>     But I could not find the
> 
>     |instance Monoid a => Monad ((,) a)|
> 
>     documented anywhere in the base package.
> 
> If you look at the list of instances under the definition of |Monad|,
> you’ll see |Monoid a => Monad ((,) a)| | /Since: 4.9.0.0/ in the list.
> Clicking on the |# Source| link takes you to the source of |GHC.Base|:
> 
> |instance Monoid a => Monad ((,) a) where (u, a) >>= k = case k a of (v,
> b) -> (u <> v, b) |

Thanks! No idea how/why I missed that. I have stared at that list for
quite some time before sending my question, just couldn' see it...

And yes, this is exactly the instance I had in mind (with Any instead of
Bool).

Cheers
Ben



More information about the Haskell-Cafe mailing list