Proposal: add isEmpty to Monoid

Dr.Koster drkoster at
Sat May 25 06:56:07 UTC 2019

I see, Thanks!


------------------ Original ------------------
From: Simon Jakobi <simon.jakobi at>
Date: Sat,May 25,2019 2:45 PM
To: Dr.Koster <drkoster at>
Cc: libraries <libraries at>
Subject: Re: Proposal: add isEmpty to Monoid

The monoid-subclasses packages provides a MonoidNull class that you could use:

Am Sa., 25. Mai 2019 um 07:56 Uhr schrieb Dr.Koster <drkoster at>:

It's often useful to have a generalized null/unit test, e.g. to check if a monadic stream `m a` reaches EOF.  A workaround is to use `Eq a, Monoid a` constraint and use `== mempty` test. But this is no only inefficient for some type, but also impossible for some monoids, such as Builders.

I propose add this test `isEmpty :: a -> Bool` to `Monoid`, to provide the ability to check if a value is the unit value.

Han Dong~
 Libraries mailing list
 Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list