packages feed

defaultable-map 1.0.0 → 1.0.1

raw patch · 4 files changed

+27/−21 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

+ CHANGELOG.md view
@@ -0,0 +1,9 @@+1.0.1++* BUG FIX: `Defaultable.Map.Generalized.insert` now correctly overrides any+  existing key+* Small fixes to documentation about how key collisions are resolved++1.0.0++* Initial release
defaultable-map.cabal view
@@ -1,25 +1,20 @@ cabal-version:      3.0 name:               defaultable-map-version:            1.0.0+version:            1.0.1 synopsis:           Applicative maps-description:        This package provides a @Defaultable@ type constructor that-                    wraps any @Map@-like type to add an optional default value. -                    Wrapping a @Map@-like type in this way permits a valid-                    @Applicative@ instance, so you can think of this as an-                    "@Applicative@ map" package.-                    .-                    This package provides both a concrete and a generalized API:-                    .-                    * The concrete API wraps @Data.Map@ for better performance-                      and type inference-                    .-                    * The generalized API works with any @Map@-like type+description:+  This package provides a `Defaultable` type constructor that+  wraps any `Map`-like type to add an optional default value. +  Wrapping a `Map`-like type in this way permits a valid+  `Applicative` instance, so you can think of this as an+  "`Applicative` map" package. bug-reports:        https://github.com/Gabriella439/defaultable-map/issues license:            BSD-3-Clause license-file:       LICENSE author:             Gabriella Gonzalez copyright:          2022 Gabriella Gonzalez maintainer:         GenuineGabby@gmail.com+extra-source-files: CHANGELOG.md  source-repository head     type:             git
src/Defaultable/Map.hs view
@@ -188,7 +188,7 @@     You can transform and combine `Defaultable` values using:      * (`<|>`) - Concatenate two `Defaultable` values, preferring keys and-      defaults from the right one+      defaults from the left one     * @do@ notation, if you enable @ApplicativeDo@     * `withDefault` - To extend a `Defaultable` value with a default value @@ -301,8 +301,8 @@  {-| Create a `Defaultable` `Map` from a `Map` ->>> fromMap (Map.fromList [('A',1),('B',2)])-Defaultable (fromList [('A',1),('B',2)]) Nothing+>>> fromMap (Map.fromList [('A',1),('B',2),('B',3)])+Defaultable (fromList [('A',1),('B',3)]) Nothing -} fromMap :: Map key value -> Defaultable (Map key) value fromMap map_ = Defaultable map_ empty@@ -317,8 +317,8 @@  {-| Create a `Defaultable` `Map` from a list of key-value pairs ->>> fromList [('A',1),('B',2)]-Defaultable (fromList [('A',1),('B',2)]) Nothing+>>> fromList [('A',1),('B',2),('B',3)]+Defaultable (fromList [('A',1),('B',3)]) Nothing -} fromList :: Ord key => [(key, value)] -> Defaultable (Map key) value fromList pairs = fromMap (Map.fromList pairs)@@ -328,11 +328,13 @@ >>> let example = fromList [('A', 1)] >>> insert ('B', 2) example Defaultable (fromList [('A',1),('B',2)]) Nothing+>>> insert ('A', 0) example+Defaultable (fromList [('A',0)]) Nothing      For bulk updates, you should instead use `fromList`/`fromMap` with (`<|>`): ->>> fromList [('B', 2), ('C', 3)] <|> example-Defaultable (fromList [('A',1),('B',2),('C',3)]) Nothing+>>> fromList [('A',0),('B', 2), ('C', 3)] <|> example+Defaultable (fromList [('A',0),('B',2),('C',3)]) Nothing -} insert     :: Ord key
src/Defaultable/Map/Generalized.hs view
@@ -57,7 +57,7 @@     -> Defaultable map value     -- ^     -> Defaultable map value-insert item defaultable = defaultable <|> singleton item+insert item defaultable = singleton item <|> defaultable  -- | Generalized version of `Defaultable.Map.withDefault` withDefault