classy-prelude 0.12.5.1 → 0.12.6
raw patch · 3 files changed
+58/−38 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- ClassyPrelude: class Prim a
- ClassyPrelude: class Monad m => PrimMonad (m :: * -> *) where type family PrimState (m :: * -> *) :: *
+ ClassyPrelude: for_ :: (Applicative f, MonoFoldable c) => c -> (Element c -> f ()) -> f ()
+ ClassyPrelude: traverse_ :: (Applicative f, MonoFoldable c) => (Element c -> f ()) -> c -> f ()
- ClassyPrelude: forM_ :: (Monad m, MonoFoldable c) => c -> (Element c -> m ()) -> m ()
+ ClassyPrelude: forM_ :: (Applicative f, MonoFoldable c) => c -> (Element c -> f ()) -> f ()
- ClassyPrelude: intercalate :: IsSequence seq => seq -> [seq] -> seq
+ ClassyPrelude: intercalate :: (MonoFoldable mono, Monoid (Element mono)) => Element mono -> mono -> Element mono
- ClassyPrelude: mapM_ :: (Monad m, MonoFoldable c) => (Element c -> m ()) -> c -> m ()
+ ClassyPrelude: mapM_ :: (Applicative f, MonoFoldable c) => (Element c -> f ()) -> c -> f ()
Files
- ChangeLog.md +6/−0
- ClassyPrelude.hs +51/−37
- classy-prelude.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,9 @@+## 0.12.6++* Regeneralize intercalate [#119](https://github.com/snoyberg/classy-prelude/pull/119)+* Add missing exports for `traverse_` and `for_`+* Generalize `mapM_` and `forM_` for GHC 7.10+ ## 0.12.5.1 * Support for QuickCheck 2.8.2
ClassyPrelude.hs view
@@ -33,13 +33,10 @@ , module Data.IORef.Lifted , module Data.Mutable -- ** Primitive (exported since 0.9.4)- , PrimMonad- , PrimState , primToPrim , primToIO , primToST , module Data.Primitive.MutVar- , Prim -- ** Debugging , trace , traceShow@@ -92,6 +89,8 @@ , repack , toList , mapM_+ , traverse_+ , for_ , sequence_ , forM_ , any@@ -192,7 +191,8 @@ import CorePrelude hiding (print, undefined, (<>), catMaybes, first, second) import Data.ChunkedZip import qualified Data.Char as Char-import Data.Sequences hiding (elem)+import Data.Sequences hiding (elem, intercalate)+import qualified Data.Sequences (intercalate) import Data.MonoTraversable import Data.Containers import Data.Builder@@ -222,9 +222,8 @@ import Data.Sequences.Lazy import GHC.Generics (Generic) -import Control.Monad.Primitive (PrimMonad, PrimState, primToPrim, primToIO, primToST)+import Control.Monad.Primitive (primToPrim, primToIO, primToST) import Data.Primitive.MutVar-import Data.Primitive.Types (Prim) import Data.Functor.Identity (Identity (..)) import Control.Monad.Reader (MonadReader, ask, ReaderT (..), Reader)@@ -298,17 +297,36 @@ length :: MonoFoldable c => c -> Int length = olength +-- Due to the Applicative-Monad-Proposal, from GHC 7.10 (base 4.8) we can+-- generalize some Monad constraints to Applicative constraints+#if MIN_VERSION_base(4,8,0)++mapM_ :: (Applicative f, MonoFoldable c) => (Element c -> f ()) -> c -> f ()+mapM_ = traverse_++forM_ :: (Applicative f, MonoFoldable c) => c -> (Element c -> f ()) -> f ()+forM_ = ofor_++#else+ mapM_ :: (Monad m, MonoFoldable c) => (Element c -> m ()) -> c -> m () mapM_ = omapM_ +forM_ :: (Monad m, MonoFoldable c) => c -> (Element c -> m ()) -> m ()+forM_ = oforM_++#endif++{-# INLINE mapM_ #-}+{-# INLINE forM_ #-}+ traverse_ :: (Applicative f, MonoFoldable c) => (Element c -> f ()) -> c -> f () traverse_ = otraverse_+{-# INLINE traverse_ #-} for_ :: (Applicative f, MonoFoldable c) => c -> (Element c -> f ()) -> f () for_ = ofor_--forM_ :: (Monad m, MonoFoldable c) => c -> (Element c -> m ()) -> m ()-forM_ = oforM_+{-# INLINE for_ #-} concatMap :: (Monoid m, MonoFoldable c) => (Element c -> m) -> c -> m concatMap = ofoldMap@@ -372,10 +390,30 @@ unions :: (MonoFoldable c, SetContainer (Element c)) => c -> Element c unions = ofoldl' union Monoid.mempty -#if !MIN_VERSION_mono_traversable(0, 9, 3)-intercalate :: (Monoid (Element c), IsSequence c) => Element c -> c -> Element c-intercalate xs xss = concat (intersperse xs xss)-#endif+intercalate :: (MonoFoldable mono, Monoid (Element mono))+ => Element mono+ -> mono+ -> Element mono+intercalate x = mconcat . intersperse x . otoList+{-# INLINE [0] intercalate #-}+{-# RULES "intercalate list" forall (x :: [a]).+ intercalate x = Data.Sequences.intercalate x . toList #-}+{-# RULES "intercalate ByteString" forall (x :: ByteString).+ intercalate x = Data.Sequences.intercalate x . toList #-}+{-# RULES "intercalate LByteString" forall (x :: LByteString).+ intercalate x = Data.Sequences.intercalate x . toList #-}+{-# RULES "intercalate Text" forall (x :: Text).+ intercalate x = Data.Sequences.intercalate x . toList #-}+{-# RULES "intercalate LText" forall (x :: LText).+ intercalate x = Data.Sequences.intercalate x . toList #-}+{-# RULES "intercalate Seq" forall (x :: Seq a).+ intercalate x = Data.Sequences.intercalate x . toList #-}+{-# RULES "intercalate Vector" forall (x :: Vector a).+ intercalate x = Data.Sequences.intercalate x . toList #-}+{-# RULES "intercalate UVector" forall (x :: Unbox a => UVector a).+ intercalate x = Data.Sequences.intercalate x . toList #-}+{-# RULES "intercalate SVector" forall (x :: Storable a => SVector a).+ intercalate x = Data.Sequences.intercalate x . toList #-} asByteString :: ByteString -> ByteString asByteString = id@@ -618,27 +656,3 @@ applyDList :: DList a -> [a] -> [a] applyDList = DList.apply {-# INLINE applyDList #-}---- | Throw a monadic exception from a String------ > erroM = throwM . userError------ Since 0.12.1-errorM :: (MonadThrow m) => String -> m a-errorM = throwM . userError---- | Throw a monadic exception from a Text------ > terroM = errorM . unpack------ Since 0.12.1-terrorM :: (MonadThrow m) => Text -> m a-terrorM = errorM . unpack---- | Throw an error from a Text------ > terror = error . unpack------ Since 0.12.1-terror :: Text -> a-terror = error . unpack
classy-prelude.cabal view
@@ -1,5 +1,5 @@ name: classy-prelude-version: 0.12.5.1+version: 0.12.6 synopsis: A typeclass-based Prelude. description: Modern best practices without name collisions. No partial functions are exposed, but modern data structures are, without requiring import lists. Qualified modules also are not needed: instead operations are based on type-classes from the mono-traversable package.