containers icon indicating copy to clipboard operation
containers copied to clipboard

Proposal: Create containers-extra package

Open m-renaud opened this issue 7 years ago • 1 comments

Background

I've just finished going through all of the open issues and pull requests and I've noticed a bunch of them are of the form "Consider adding x to the Y api", and the discussion usually ends with, "I like this idea, but this is a somewhat special and the api is already huge, so probably not."

See below for a list of open issues that request that things be added to containers. Many of these are reasonable requests and things that not everyone should need to write themselves, but also don't quite belong in the core containers API. By creating an official containers-extra package we can provide the "extra" API functions to reduce code duplication in other libraries, (potentially) user more efficient implementations using the Internals, and use it as a test bed to see which operations are widely used to give us data for what should be included in the core api.

Open API Requests

  • Add Data.Set.catMaybes and Data.Set.mapMaybe? (#346)
    • mapMaybe :: Ord b => (a -> Maybe b) -> Set a -> Set b
    • catMaybes :: Ord a => Set (Maybe a) -> Set a
    • Note: No real desire for catMaybes
  • Unfold for Maps and Easier Conversion from Foldable (#338)
    • fromFoldable :: (Ord k, Foldable f) => (a -> (k,v)) -> f a -> Map k v
  • Applicative/monadic versions of adjust/update/alter functions (#278)
    • Note: alterF already added, no real desire for the others
  • Data.Sequence.{splitAtR, takeR, dropR} (#159)
    • splitAtR :: Int -> Seq a -> (Seq a, Seq a)
    • takeR :: Int -> Seq a -> Seq a
    • drop :: Int -> Seq a -> Seq a
  • Map.differenceSet (#158)
    • differenceSet :: Ord k => Map k a -> Set k -> Map k a
  • Map.fromListWithDefault (#386)
    • fromListWithDefault :: Ord k => b -> (a -> b -> b) -> [(k, a)] -> Map k b
  • Add Data.Sequence.filterM (#120)
    • filterM :: Applicative f => (a -> f Bool) -> Seq a -> f (Seq a)
  • Unicode 2d drawing for Data.Tree (#344)
  • Add Data.Map.toSet (#391)
    • toSet :: Map k v -> Set (k, v)
  • add Data.Set.unionIntersection (#162)
    • unionIntersection :: (Ord a) => Set a -> Set a -> (Set a, Set a)
  • Data.Map lacks unionsWithKey (#137)
    • unionsWithKey :: Ord k => (k -> a -> a -> a) -> [Map k a] -> Map k a
  • ~~Add foldMapWithIndex and traverseWithIndex (#89)~~
  • ~~Consider adding fromFunction to Data.IntMap (#96)~~
    • ~~fromFunction :: Int -> Int -> (Int -> a) -> IntMap a~~
  • Map.traverseWithKey_? (#422)
    • traverseWithKey :: Applicative t => (k -> a -> t b) -> Map k a -> t (Map k b) already exists, what would the type of traverseWithKey_ be?
  • add ordNub somewhere in containers (#439)
    • ordNub :: Ord a => [a] -> [a] (uses Set under the hood)
    • possibly going into containers proper(?)
  • Add intersections, intersectionsWith (#359)
    • intersections :: NonEmpty (IntMap a) -> IntMap a
    • intersectionsWith :: (a -> a -> a) -> NonEmpty (IntMap a) -> IntMap a
    • somewhat controversial

m-renaud avatar Dec 27 '17 01:12 m-renaud

I don't think it would be bad to have such a package, but I have very little sense of what would go in it. Some things above are now in containers, some should probably be added, some are kind of bad ideas (IMO) and some might go well in an extras package.

treeowl avatar Dec 29 '17 01:12 treeowl