containers: intersections for Set, along with Semigroup newtype

David Feuer david.feuer at gmail.com
Sun Dec 6 19:01:18 UTC 2020


intersections [] = empty is unacceptable to me. The options that make sense
to me are the nonempty (ideally Foldable1) one, one producing a Maybe, and
I guess even one that throws an error on an empty list (ouch).

On Sun, Dec 6, 2020, 1:50 PM Sven Panne <svenpanne at gmail.com> wrote:

> Am So., 6. Dez. 2020 um 07:20 Uhr schrieb Reed Mullanix <
> reedmullanix at gmail.com>:
>
>> [...]
>>   intersections :: Ord a => NonEmpty (Set a) -> Set a
>>   intersections (s :| ss) = Foldable.foldl' intersection s ss
>> [...]
>>
>
> Why NonEmpty? I would expect "intersections [] = Set.empty", because the
> result contains all the elements which are in all sets, i.e. none. That's
> at least my intuition, is there some law which this would violate?
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20201206/fdb9e791/attachment.html>


More information about the Libraries mailing list