packages feed

nonempty-containers 0.3.2.0 → 0.3.3.0

raw patch · 3 files changed

+31/−3 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.Containers.NonEmpty: pattern IsNonEmpty :: HasNonEmpty s => NE s -> s
- Data.Containers.NonEmpty: pattern IsEmpty :: HasNonEmpty s => s
- Data.IntMap.NonEmpty: pattern IsEmpty :: IntMap a
- Data.IntMap.NonEmpty: pattern IsNonEmpty :: NEIntMap a -> IntMap a
- Data.IntSet.NonEmpty: pattern IsEmpty :: IntSet
- Data.IntSet.NonEmpty: pattern IsNonEmpty :: NEIntSet -> IntSet
- Data.Map.NonEmpty: pattern IsEmpty :: Map k a
- Data.Map.NonEmpty: pattern IsNonEmpty :: NEMap k a -> Map k a
- Data.Sequence.NonEmpty: pattern (:||>) :: Seq a -> a -> NESeq a
- Data.Sequence.NonEmpty: pattern IsEmpty :: Seq a
- Data.Sequence.NonEmpty: pattern IsNonEmpty :: NESeq a -> Seq a
- Data.Sequence.NonEmpty.Internal: pattern (:||>) :: Seq a -> a -> NESeq a
- Data.Set.NonEmpty: pattern IsEmpty :: Set a
- Data.Set.NonEmpty: pattern IsNonEmpty :: NESet a -> Set a
+ Data.Containers.NonEmpty: onNonEmpty :: HasNonEmpty s => (NE s -> r) -> s -> Maybe r
+ Data.Containers.NonEmpty: overNonEmpty :: (HasNonEmpty s, HasNonEmpty t) => (NE s -> NE t) -> s -> t

Files

CHANGELOG.md view
@@ -1,12 +1,21 @@ Changelog ========= +Version 0.3.3.0+---------------++*December 3, 2019*++<https://github.com/mstksg/nonempty-containers/releases/tag/v0.3.3.0>++*   Add `overNonEmpty` and `onNonEmpty` in *Data.Containers.NonEmpty*.+ Version 0.3.1.0 ---------------  *October 21, 2019* -<https://github.com/mstksg/nonempty-containers/releases/tag/v0.3.2.0>+<https://github.com/mstksg/nonempty-containers/releases/tag/v0.3.3.0>  *   Add `HasNonEmpty` instance for *nonempty-vector* *   Changed `splitLookup` to use `These` instead of a tuple of `Maybe`s.
nonempty-containers.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: b3957939f119319cc87a4a5bed720ba0d54e8e7a4ddff1240df072483ee72097+-- hash: 99b2f1d8a05c4c65da0f4e80d7fe63f0bba58499425adb66fc50f03895929c56  name:           nonempty-containers-version:        0.3.2.0+version:        0.3.3.0 synopsis:       Non-empty variants of containers data types, with full API description:    Efficient and optimized non-empty versions of types from /containers/.                 Inspired by /non-empty-containers/ library, except attempting a more
src/Data/Containers/NonEmpty.hs view
@@ -24,6 +24,8 @@ module Data.Containers.NonEmpty (     HasNonEmpty(..)   , pattern IsNonEmpty, pattern IsEmpty+  , overNonEmpty+  , onNonEmpty   ) where  import           Data.IntMap            (IntMap)@@ -107,6 +109,23 @@     unsafeToNonEmpty = fromMaybe e . nonEmpty       where         e = errorWithoutStackTrace "unsafeToNonEmpty: empty input provided"++-- | Useful function for mapping over the "non-empty" representation of+-- a type.+--+-- @since 0.3.3.0+overNonEmpty :: (HasNonEmpty s, HasNonEmpty t) => (NE s -> NE t) -> s -> t+overNonEmpty f = withNonEmpty empty (fromNonEmpty . f)++-- | Useful function for applying a function on the "non-empty"+-- representation of a type.+--+-- If you want a continuation taking @'NE' s -> 'Maybe r'@, you can+-- use @'withNonEmpty' 'Nothing'@.+--+-- @since 0.3.3.0+onNonEmpty :: HasNonEmpty s => (NE s -> r) -> s -> Maybe r+onNonEmpty f = withNonEmpty Nothing (Just . f)  instance HasNonEmpty [a] where     type NE [a] = NonEmpty a