<div dir="ltr"><div>In a perfect world we would use something like Foldable1 from semigroupoids, but sadly that is not in base.</div><div>However, this is exactly why I proposed the Intersection newtype, as it would make it nice and easy to use with a Foldable1</div><div>like type class.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 6, 2020 at 10:27 AM Alexandre Rodrigues Baldé <<a href="mailto:alexandreR_B@outlook.com">alexandreR_B@outlook.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="PT">
<div class="gmail-m_5589250867535076100WordSection1">
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Arial",sans-serif">Sounds like a good idea, could it be possible to use a typeclass instead of `NonEmpty (Set a)`?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Arial",sans-serif">I recall needing this a few times, but not over a NonEmpty.<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><img style="width: 5.7833in; height: 0.025in;" id="gmail-m_5589250867535076100Horizontal_x0020_Line_x0020_1" src="cid:176395969f9de41de1e1" width="555" height="2"><u></u><u></u></p>
<div id="gmail-m_5589250867535076100divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">De:</span></b><span style="color:black"> Libraries <<a href="mailto:libraries-bounces@haskell.org" target="_blank">libraries-bounces@haskell.org</a>> em nome de Reed Mullanix <<a href="mailto:reedmullanix@gmail.com" target="_blank">reedmullanix@gmail.com</a>><br>
<b>Enviado:</b> Sunday, December 6, 2020 6:20:02 AM<br>
<b>Para:</b> Haskell Libraries <<a href="mailto:libraries@haskell.org" target="_blank">libraries@haskell.org</a>><br>
<b>Assunto:</b> containers: intersections for Set, along with Semigroup newtype</span>
<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">Hey all,<u></u><u></u></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.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">  intersections :: Ord a => NonEmpty (Set a) -> Set a<br>
  intersections (s :| ss) = Foldable.foldl' intersection s ss<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">In a similar vein, we may as well add the following newtype + instance combo:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">  newtype Intersection a = Intersection { getIntersection :: Set a }<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></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<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">Would love to hear everyone's thoughts on this!<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks<u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal">Reed Mullanix<u></u><u></u></p>
</div>
</div>

</blockquote></div>