# containers: intersections for Set, along with Semigroup newtype

David Casperson casper at unbc.ca
Mon Dec 7 00:46:55 UTC 2020

```Intersection is a lattice operation, whose identity element is the "whole
universe" not the empty set.

Imagine if we had an intersections :: [Set a] -> Set a

we would expect it have the law
intersections (a ++ b) = (intersections a) `intersect` (intersections b)

now let b be [] and aa == intersections a, and we get
aa == aa `intersect` (intersections [])
and this must hold for all aa, which is impossible unless we have some
kind of universe set.

David
--
David Casperson, PhD, R.P.,                  |  David.Casperson at unbc.ca
Associate Professor and Chair,               |  (250)   960-6672 Fax 960-5544
Computer Science                             |  3333 University Way
University of Northern British Columbia      |  Prince George, BC   V2N 4Z9

Sven Panne, on 2020-12-06, you wrote:

> From: Sven Panne <svenpanne at gmail.com>
> To: Reed Mullanix <reedmullanix at gmail.com>
> Date: Sun, 6 Dec 2020 10:50:13
> Subject: Re: containers: intersections for Set, along with Semigroup newtype
> Message-ID:
>     <CANBN=muqE8tE11UCGgYYuUEKP=SN19TAQ7_3wE68v46583H-=A at mail.gmail.com>
>
>
>
> 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?
>
>
-------------- next part --------------
_______________________________________________
Libraries mailing list