First consider how `and` and `or` work for booleans. and (x ++ y) == and x && and y For this to work we need `and [] == True` or (x ++ y) == or x || or y For this to work we need `or [] == False` and and or are duals of each other. There’s an analogue here to union and intersection which are also duals of each other. We have: unions (x ++ y) == union (unions x) (unions y) This requires `union [] == []` since any list xs could be split as `[] ++ xs` We'd like to have: intersections (x ++ y) == intersect (intersections x) (intersections y) For this kind of splitting property to make sense for intersections we’d need `intersections [] == listOfAllElementsOfThisType`, but it’s not easy to construct that list of all elements in general. So instead we punt on the problem and refuse to define intersections on an empty list. -glguy
On Dec 6, 2020, at 10:50 AM, Sven Panne
wrote: Am So., 6. Dez. 2020 um 07:20 Uhr schrieb Reed Mullanix
mailto:reedmullanix@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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries