packages feed

mono-traversable 1.0.4.0 → 1.0.5.0

raw patch · 3 files changed

+118/−88 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.MonoTraversable: instance Data.MonoTraversable.MonoFoldable (Data.Set.Base.Set e)
+ Data.MonoTraversable: instance GHC.Classes.Ord e => Data.MonoTraversable.MonoFoldable (Data.Set.Base.Set e)
- Data.MonoTraversable: class MonoFoldable mono where ofoldMap = foldMap ofoldr = foldr ofoldl' = foldl' otoList t = build (\ mono n -> ofoldr mono n t) oall f = getAll . ofoldMap (All . f) oany f = getAny . ofoldMap (Any . f) onull = oall (const False) olength = ofoldl' (\ i _ -> i + 1) 0 olength64 = ofoldl' (\ i _ -> i + 1) 0 ocompareLength c0 i0 = olength c0 `compare` fromIntegral i0 otraverse_ f = ofoldr ((*>) . f) (pure ()) ofor_ = flip otraverse_ omapM_ = otraverse_ oforM_ = flip omapM_ ofoldlM f z0 xs = ofoldr f' return xs z0 where f' x k z = f z x >>= k ofoldMap1Ex f = fromMaybe (error "Data.MonoTraversable.ofoldMap1Ex") . getOption . ofoldMap (Option . Just . f) ofoldr1Ex = foldr1 ofoldl1Ex' = foldl1 headEx = ofoldr const (error "Data.MonoTraversable.headEx: empty") lastEx = ofoldl1Ex' (flip const) unsafeHead = headEx unsafeLast = lastEx maximumByEx f = ofoldl1Ex' go where go x y = case f x y of { LT -> y _ -> x } minimumByEx f = ofoldl1Ex' go where go x y = case f x y of { GT -> y _ -> x }
+ Data.MonoTraversable: class MonoFoldable mono where ofoldMap = foldMap ofoldr = foldr ofoldl' = foldl' otoList t = build (\ mono n -> ofoldr mono n t) oall f = getAll . ofoldMap (All . f) oany f = getAny . ofoldMap (Any . f) onull = oall (const False) olength = ofoldl' (\ i _ -> i + 1) 0 olength64 = ofoldl' (\ i _ -> i + 1) 0 ocompareLength c0 i0 = olength c0 `compare` fromIntegral i0 otraverse_ f = ofoldr ((*>) . f) (pure ()) ofor_ = flip otraverse_ omapM_ = otraverse_ oforM_ = flip omapM_ ofoldlM f z0 xs = ofoldr f' return xs z0 where f' x k z = f z x >>= k ofoldMap1Ex f = fromMaybe (error "Data.MonoTraversable.ofoldMap1Ex") . getOption . ofoldMap (Option . Just . f) ofoldr1Ex = foldr1 ofoldl1Ex' = foldl1 headEx = ofoldr const (error "Data.MonoTraversable.headEx: empty") lastEx = ofoldl1Ex' (flip const) unsafeHead = headEx unsafeLast = lastEx maximumByEx f = ofoldl1Ex' go where go x y = case f x y of { LT -> y _ -> x } minimumByEx f = ofoldl1Ex' go where go x y = case f x y of { GT -> y _ -> x } oelem e = elem e . otoList onotElem e = notElem e . otoList

Files

ChangeLog.md view
@@ -1,3 +1,8 @@+## 1.0.5.0++* Move `oelem` and `onotElem` into the `MonoFoldable` class [#133](https://github.com/snoyberg/mono-traversable/issues/133)+    * Change `instance MonoFoldable (Set e)` to `instance Ord e => MonoFoldable (Set e)`+ ## 1.0.4.0  * Add `dropEnd` function to the `IsSequence` class, and a specialized implementation for `Text`
mono-traversable.cabal view
@@ -1,75 +1,96 @@-name:                mono-traversable-version:             1.0.4.0-synopsis:            Type classes for mapping, folding, and traversing monomorphic containers-description:         Monomorphic variants of the Functor, Foldable, and Traversable typeclasses. If you understand Haskell's basic typeclasses, you understand mono-traversable. In addition to what you are used to, it adds on an IsSequence typeclass and has code for marking data structures as non-empty.-homepage:            https://github.com/snoyberg/mono-traversable-license:             MIT-license-file:        LICENSE-author:              Michael Snoyman, John Wiegley, Greg Weber-maintainer:          michael@snoyman.com-category:            Data-build-type:          Simple-extra-source-files:  README.md-                     ChangeLog.md-cabal-version:       >=1.10+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: f018b4ea166006fa7ec7d69a0b78999cc474978f817b1ede26524a3982e90f9e -library-  ghc-options: -Wall-  exposed-modules:     Data.MonoTraversable-                       Data.MonoTraversable.Unprefixed-                       Data.Containers-                       Data.Sequences-                       Data.NonNull-  build-depends:       base >= 4.7 && < 5-                     , containers >= 0.4-                     , unordered-containers >=0.2-                     , hashable-                     , bytestring >= 0.9-                     , text >=0.11-                     , transformers >=0.3-                     , vector >=0.10-                     , vector-algorithms >= 0.6-                     , split >= 0.2+name:           mono-traversable+version:        1.0.5.0+synopsis:       Type classes for mapping, folding, and traversing monomorphic containers+description:    Please see the README at <https://www.stackage.org/package/mono-traversable>+category:       Data+homepage:       https://github.com/snoyberg/mono-traversable#readme+bug-reports:    https://github.com/snoyberg/mono-traversable/issues+author:         Michael Snoyman, John Wiegley, Greg Weber+maintainer:     michael@snoyman.com+license:        MIT+license-file:   LICENSE+build-type:     Simple+cabal-version:  >= 1.10 -  if impl(ghc < 8.0)-    build-depends:     semigroups >= 0.10+extra-source-files:+    ChangeLog.md+    README.md -  hs-source-dirs:      src-  default-language:    Haskell2010+source-repository head+  type: git+  location: https://github.com/snoyberg/mono-traversable +library+  hs-source-dirs:+      src+  ghc-options: -Wall+  build-depends:+      base >=4.7 && <5+    , bytestring >=0.9+    , containers >=0.4+    , hashable+    , split >=0.2+    , text >=0.11+    , transformers >=0.3+    , unordered-containers >=0.2+    , vector >=0.10+    , vector-algorithms >=0.6+  if impl(ghc <8.0)+    build-depends:+        semigroups >=0.10+  exposed-modules:+      Data.Containers+      Data.MonoTraversable+      Data.MonoTraversable.Unprefixed+      Data.NonNull+      Data.Sequences+  other-modules:+      Paths_mono_traversable+  default-language: Haskell2010+ test-suite test-  main-is:             main.hs-  type:                exitcode-stdio-1.0-  hs-source-dirs:      test-  other-modules:       Spec-  default-language:    Haskell2010-  ghc-options:         -O0-  build-depends:       base-                     , mono-traversable-                     , bytestring-                     , text-                     , hspec-                     , HUnit-                     , transformers-                     , vector-                     , QuickCheck-                     , semigroups-                     , containers-                     , unordered-containers-                     , foldl+  type: exitcode-stdio-1.0+  main-is: main.hs+  hs-source-dirs:+      test+  ghc-options: -O0+  build-depends:+      HUnit+    , QuickCheck+    , base+    , bytestring+    , containers+    , foldl+    , hspec+    , mono-traversable+    , semigroups+    , text+    , transformers+    , unordered-containers+    , vector+  other-modules:+      Spec+      Paths_mono_traversable+  default-language: Haskell2010  benchmark sorting-    type: exitcode-stdio-1.0-    hs-source-dirs: bench-    build-depends:  base-                  , criterion-                  , mono-traversable-                  , vector-                  , mwc-random-    main-is:        sorting.hs-    ghc-options:    -Wall -O2-    default-language:    Haskell2010--source-repository head-  type: git-  location: git://github.com/snoyberg/mono-traversable.git+  type: exitcode-stdio-1.0+  main-is: sorting.hs+  hs-source-dirs:+      bench+  ghc-options: -Wall -O2+  build-depends:+      base+    , criterion+    , mono-traversable+    , mwc-random+    , vector+  other-modules:+      Paths_mono_traversable+  default-language: Haskell2010
src/Data/MonoTraversable.hs view
@@ -415,6 +415,16 @@                 _  -> x     {-# INLINE minimumByEx #-} +    -- | Checks if the monomorphic container includes the supplied element.+    oelem :: Eq (Element mono) => Element mono -> mono -> Bool+    oelem e = List.elem e . otoList+    {-# INLINE [0] oelem #-}++    -- | Checks if the monomorphic container does not include the supplied element.+    onotElem :: Eq (Element mono) => Element mono -> mono -> Bool+    onotElem e = List.notElem e . otoList+    {-# INLINE [0] onotElem #-}+ instance MonoFoldable S.ByteString where     ofoldMap f = ofoldr (mappend . f) mempty     ofoldr = S.foldr@@ -424,6 +434,8 @@     oany = S.any     onull = S.null     olength = S.length+    oelem = S.elem+    onotElem = S.notElem      omapM_ f (Unsafe.PS fptr offset len) = do         let start = Unsafe.unsafeForeignPtrToPtr fptr `plusPtr` offset@@ -470,6 +482,8 @@     {-# INLINE headEx #-}     {-# INLINE lastEx #-}     {-# INLINE unsafeHead #-}+    {-# INLINE oelem #-}+    {-# INLINE onotElem #-} {-# RULES "strict ByteString: ofoldMap = concatMap" ofoldMap = S.concatMap #-}  instance MonoFoldable L.ByteString where@@ -486,6 +500,9 @@     ofoldl1Ex' = L.foldl1'     headEx = L.head     lastEx = L.last+    oelem = L.elem+    onotElem = L.notElem+     {-# INLINE ofoldMap #-}     {-# INLINE ofoldr #-}     {-# INLINE ofoldl' #-}@@ -499,6 +516,8 @@     {-# INLINE ofoldl1Ex' #-}     {-# INLINE headEx #-}     {-# INLINE lastEx #-}+    {-# INLINE oelem #-}+    {-# INLINE onotElem #-} {-# RULES "lazy ByteString: ofoldMap = concatMap" ofoldMap = L.concatMap #-}  instance MonoFoldable T.Text where@@ -633,9 +652,13 @@     {-# INLINE unsafeHead #-}     {-# INLINE maximumByEx #-}     {-# INLINE minimumByEx #-}-instance MonoFoldable (Set e) where+instance Ord e => MonoFoldable (Set e) where     olength = Set.size+    oelem = Set.member+    onotElem = Set.notMember     {-# INLINE olength #-}+    {-# INLINE oelem #-}+    {-# INLINE onotElem #-} instance MonoFoldable (HashSet e)  instance U.Unbox a => MonoFoldable (U.Vector a) where@@ -830,25 +853,6 @@ #endif osequence_ = omapM_ id {-# INLINE osequence_ #-}---- | Checks if the monomorphic container includes the supplied element.-oelem :: (MonoFoldable mono, Eq (Element mono)) => Element mono -> mono -> Bool-oelem e = List.elem e . otoList-{-# INLINE [0] oelem #-}---- | Checks if the monomorphic container does not include the supplied element.-onotElem :: (MonoFoldable mono, Eq (Element mono)) => Element mono -> mono -> Bool-onotElem e = List.notElem e . otoList-{-# INLINE [0] onotElem #-}--{-# RULES "strict ByteString elem" oelem = S.elem #-}-{-# RULES "strict ByteString notElem" onotElem = S.notElem #-}--{-# RULES "lazy ByteString elem" oelem = L.elem #-}-{-# RULES "lazy ByteString notElem" onotElem = L.notElem #-}--{-# RULES "Set elem" forall (k :: Ord k => k). oelem k = Set.member k #-}-{-# RULES "Set notElem" forall (k :: Ord k => k). onotElem k = Set.notMember k #-}  -- | Get the minimum element of a monomorphic container. --