Re: Adding a "Map k a -> Set (Arg k a)" function to containers

David Feuer <[email protected]> Thu, 27 Jan 2022 20:35:00 -0500
Newsgroups gmane.comp.lang.haskell.libraries
Message-ID <CAMgWh9uY3qA6m992qJ4yVUFtj4ySBx4iLoP42kUzRhdc2taCvw@mail.gmail.com>
--===============1611155053028801122==
Content-Type: multipart/alternative; boundary="00000000000026af0d05d69a72ac"

--00000000000026af0d05d69a72ac
Content-Type: text/plain; charset="UTF-8"

Sorry, I meant *Map* is strict in its keys. Set is too, but that's not
relevant to my concern.

On Thu, Jan 27, 2022, 8:34 PM David Feuer <[email protected]> wrote:

> I have one minor operational concern. Set is strict in its keys, so code
> doesn't have to check whether a key is evaluated when case matching on it.
> Arg, on the other hand, is lazy in both arguments. So this function throws
> away evaluatedness information, which is always a bit sad.
>
> Separately, I'd love see:
>
> 1. A function going the other way.
> 2. Unsafe mapMonotonic-style functions generalizing both.
>
> On Thu, Jan 27, 2022, 8:25 PM Joseph C. Sible <[email protected]>
> wrote:
>
>> I opened https://github.com/haskell/containers/issues/814 about adding
>> this function to the containers package:
>>
>> import qualified Data.Map.Internal as Map
>> import qualified Data.Set.Internal as Set
>> import Data.Semigroup (Arg(..))
>>
>> mapToArgSet :: Map.Map k a -> Set.Set (Arg k a)
>> mapToArgSet Map.Tip = Set.Tip
>> mapToArgSet (Map.Bin sz k v l r) = Set.Bin sz (Arg k v) (mapToArgSet
>> l) (mapToArgSet r)
>>
>> Does anyone have any suggestions or improvements for this? In
>> particular, I'm sure there's a less clunky name that I just can't
>> think of.
>>
>> Thanks,
>>
>> Joseph C. Sible
>> _______________________________________________
>> Libraries mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>

--00000000000026af0d05d69a72ac
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">Sorry, I meant *Map* is strict in its keys. Set is too, b=
ut that&#39;s not relevant to my concern.</div><br><div class=3D"gmail_quot=
e"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, Jan 27, 2022, 8:34 PM Davi=
d Feuer &lt;<a href=3D"mailto:[email protected]">[email protected]<=
/a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0=
 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"auto">I =
have one minor operational concern. Set is strict in its keys, so code does=
n&#39;t have to check whether a key is evaluated when case matching on it. =
Arg, on the other hand, is lazy in both arguments. So this function throws =
away evaluatedness information, which is always a bit sad.<div dir=3D"auto"=
><br></div><div dir=3D"auto">Separately, I&#39;d love see:</div><div dir=3D=
"auto"><br></div><div dir=3D"auto">1. A function going the other way.</div>=
<div dir=3D"auto">2. Unsafe mapMonotonic-style functions generalizing both.=
</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_=
attr">On Thu, Jan 27, 2022, 8:25 PM Joseph C. Sible &lt;<a href=3D"mailto:j=
[email protected]" target=3D"_blank" rel=3D"noreferrer">josephcsible@gm=
ail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"=
margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I opened <a =
href=3D"https://github.com/haskell/containers/issues/814" rel=3D"noreferrer=
 noreferrer noreferrer" target=3D"_blank">https://github.com/haskell/contai=
ners/issues/814</a> about adding<br>
this function to the containers package:<br>
<br>
import qualified Data.Map.Internal as Map<br>
import qualified Data.Set.Internal as Set<br>
import Data.Semigroup (Arg(..))<br>
<br>
mapToArgSet :: Map.Map k a -&gt; Set.Set (Arg k a)<br>
mapToArgSet Map.Tip =3D Set.Tip<br>
mapToArgSet (Map.Bin sz k v l r) =3D Set.Bin sz (Arg k v) (mapToArgSet<br>
l) (mapToArgSet r)<br>
<br>
Does anyone have any suggestions or improvements for this? In<br>
particular, I&#39;m sure there&#39;s a less clunky name that I just can&#39=
;t<br>
think of.<br>
<br>
Thanks,<br>
<br>
Joseph C. Sible<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href=3D"mailto:[email protected]" rel=3D"noreferrer noreferrer" targ=
et=3D"_blank">[email protected]</a><br>
<a href=3D"http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel=
=3D"noreferrer noreferrer noreferrer" target=3D"_blank">http://mail.haskell=
.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>
</blockquote></div>

--00000000000026af0d05d69a72ac--

--===============1611155053028801122==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KTGlicmFyaWVz
IG1haWxpbmcgbGlzdApMaWJyYXJpZXNAaGFza2VsbC5vcmcKaHR0cDovL21haWwuaGFza2VsbC5v
cmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL2xpYnJhcmllcwo=

--===============1611155053028801122==--