kowainik / slist

♾️ Sized list
https://kowainik.github.io/projects/slist
Mozilla Public License 2.0
46 stars 6 forks source link

[RFC] Integration with `containers` #35

Closed chshersh closed 3 years ago

chshersh commented 4 years ago

While using slist, I've noticed that sometimes I want to convert Map/Set to slist more efficiently than using the slist function. I'm thinking about adding integration with containers and providing functions:

mapToVals :: Map k v -> Slist v
mapToKeys :: Map k v -> Slist k
mapToPairs :: Map k v -> Slist (k, v)

setToSlist :: Set a -> Slist a

If we depend on containers, we also can provide a more efficient versions of some helpful functions:

ordNub :: Ord a => Slist a -> Slist a
countUnique :: Ord a => Slist a -> Int  -- number of unique elements
vrom911 commented 4 years ago

Do you think it worth to create a separate package slist-containers for that? I personally feel that this would be a better solution than expanding this package itself, but I can see some downsides too.

chshersh commented 4 years ago

@vrom911 I thought about that as well. On the one hand, containers is a boot library and adding it to dependency doesn't bring the extra cost in terms of build times. On the other hand, slist already provides quite big and useful API and there's some sense in keeping this API under control and depending only on base. I imagine there could be a lot of functions to work with containers in some future. Maintaining a separate package is more challenging, but most likely also a more proper solution.