Adding a "Map k a -> Set (Arg k a)" function to containers
David Feuer
david.feuer at gmail.com
Fri Jan 28 01:35:00 UTC 2022
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 <david.feuer at gmail.com> 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 <josephcsible at gmail.com>
> 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
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20220127/405de803/attachment.html>
More information about the Libraries
mailing list