<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:"Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="PT">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif">Sounds like a good idea, could it be possible to use a typeclass instead of `NonEmpty (Set a)`?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif">I recall needing this a few times, but not over a NonEmpty.<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><img width="555" height="2" style="width:5.7833in;height:.025in" id="Horizontal_x0020_Line_x0020_1" src="cid:image001.png@01D6CBFD.46F1BB60"><o:p></o:p></p>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">De:</span></b><span style="color:black"> Libraries <libraries-bounces@haskell.org> em nome de Reed Mullanix <reedmullanix@gmail.com><br>
<b>Enviado:</b> Sunday, December 6, 2020 6:20:02 AM<br>
<b>Para:</b> Haskell Libraries <libraries@haskell.org><br>
<b>Assunto:</b> containers: intersections for Set, along with Semigroup newtype</span>
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hey all,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I've found myself reaching for the following function a couple of times now, so I figured it might make a good addition.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">  intersections :: Ord a => NonEmpty (Set a) -> Set a<br>
  intersections (s :| ss) = Foldable.foldl' intersection s ss<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">In a similar vein, we may as well add the following newtype + instance combo:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">  newtype Intersection a = Intersection { getIntersection :: Set a }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">  instance (Ord a) => Semigroup (Intersection a) where<br>
      (Intersection a) <> (Intersection b) = Intersection $ intersection a b<br>
      stimes = stimesIdempotent<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Would love to hear everyone's thoughts on this!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks<o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal">Reed Mullanix<o:p></o:p></p>
</div>
</body>
</html>