packages feed

universum 1.7.3 → 1.8.0

raw patch · 17 files changed

+216/−23 lines, 17 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Universum: (&) :: a -> (a -> b) -> b
- Universum: (<&>) :: Functor f => f a -> (a -> b) -> f b
- Universum: infixl 1 <&>
- Universum: type Traversal s t a b = forall (f :: Type -> Type). Applicative f => a -> f b -> s -> f t
- Universum.Base: concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
- Universum.Monad.Reexport: listToMaybe :: [a] -> Maybe a
- Universum.Monoid: Option :: Maybe a -> Option a
- Universum.Monoid: [getOption] :: Option a -> Maybe a
- Universum.Monoid: newtype Option a
- Universum.String.Reexport: readMaybe :: Read a => String -> Maybe a
+ Universum: type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
+ Universum.Container: concatMap :: Container c => (Element c -> [b]) -> c -> [b]
+ Universum.Container.Class: concatMap :: Container c => (Element c -> [b]) -> c -> [b]
+ Universum.Function: (&) :: a -> (a -> b) -> b
+ Universum.Function: infixl 1 &
+ Universum.Functor.Reexport: (<&>) :: Functor f => f a -> (a -> b) -> f b
+ Universum.Functor.Reexport: infixl 1 <&>
+ Universum.List.Reexport: groupAllWith :: Ord b => (a -> b) -> [a] -> [NonEmpty a]
+ Universum.List.Reexport: groupBy :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a]
+ Universum.List.Reexport: groupWith :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a]
+ Universum.String.Conversion: readMaybe :: forall b a. (ToString a, Read b) => a -> Maybe b
- Universum: infixl 8 ^.
+ Universum: infixl 8 ^?
- Universum: infixr 4 %~
+ Universum: infixr 4 .~
- Universum.List.Reexport: group :: Eq a => [a] -> [[a]]
+ Universum.List.Reexport: group :: (Foldable f, Eq a) => f a -> [NonEmpty a]

Files

CHANGES.md view
@@ -1,6 +1,34 @@ Unreleased ===== +1.8.0+=====++* [#252](https://github.com/serokell/universum/pull/252):+  Remove `Option` re-export. Use `Maybe` instead.++* [#176](https://github.com/serokell/universum/issues/176):+  Deprecate `note`.++* [#206](https://github.com/serokell/universum/issues/206):+  Remove `listToMaybe`.+  _Migration guide:_ use `safeHead` directly with functions from+  `Universum.Container` instead.++* [#182](https://github.com/serokell/universum/issues/182):+  Deprecate `microlens` and `microlens-mtl` dependencies.++* [#165](https://github.com/serokell/universum/issues/165):+  Change the type of `readMaybe` from `readMaybe :: Read a => String -> Maybe a`+  to it's polymorphic version `readMaybe :: forall b a. (ToString a, Read b) => a -> Maybe b`.++* [#199](https://github.com/serokell/universum/issues/199):+  Change type of `concatMap` from `concatMap :: Foldable f => (a -> [b]) -> t a -> [b]`+  to `concatMap :: Container c => (Element c -> [b]) -> c -> [b]`.++* [250](https://github.com/serokell/universum/issues):+  Replace `group` export from `Data.List` with `group`, `groupBy`, `groupWith` and `groupAllWith` from `Data.List.NonEmpty`.+ 1.7.3 ===== 
CONTRIBUTING.md view
@@ -66,8 +66,8 @@ However, 4 approvals (at least 3 from Serokell) are necessary for inclusion into a milestone. 2 disapprovals from Serokell or 4 disapprovals in total are enough to prevent the issue from getting into a milestone. If an issue is about removal of something (`x`), it should be done in two steps.-The first step is deprecation of `x` which happens in a `breaking` release.-The second step is deprecation of `x` which happens in another `breaking` release after deprecation of `x`.+The first step is to deprecate `x` which happens in a `breaking` release.+The second step is to delete `x` which happens in another `breaking` release after deprecating `x`. There can't be more than one breaking release in less than 5 weeks.  Note: approval of any PR implies that the person who approves it confirms that the PR corresponds to the issue mentioned there and the issue has a correct type.
benchmark/Main.hs view
@@ -72,7 +72,7 @@       ]    groupSort :: [a] -> [a]-  groupSort = map Unsafe.head . group . sort+  groupSort = map NonEmpty.head . group . sort    safeSort :: [a] -> [a]   safeSort = map NonEmpty.head . NonEmpty.group . sort
src/Universum.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE Trustworthy #-}+{-# LANGUAGE RankNTypes #-}  {- | Main module that reexports all functionality allowed to use without importing any other modules. Just add next lines to your@@ -80,8 +81,26 @@        , module Universum.VarArg           -- * Lenses-       , module Lens.Micro-       , module Lens.Micro.Mtl+       , Lens+       , Lens'+       , Traversal+       , Traversal'+       , over+       , set+       , (%~)+       , (.~)+       , (^.)+       , (^..)+       , (^?)+       , _1+       , _2+       , _3+       , _4+       , _5+       , preuse+       , preview+       , use+       , view        ) where  import Universum.Applicative@@ -104,6 +123,95 @@ import Universum.VarArg  -- Lenses-import Lens.Micro (Lens, Lens', Traversal, Traversal', over, set, (%~), (&), (.~), (<&>), (^.),-                   (^..), (^?), _1, _2, _3, _4, _5)-import Lens.Micro.Mtl (preuse, preview, use, view)+import qualified Lens.Micro (ASetter, Getting, over, set, (%~), (.~), (^.),+                             (^..), (^?), _1, _2, _3, _4, _5)+import qualified Lens.Micro.Mtl (preuse, preview, use, view)+import Lens.Micro.Internal (Field1, Field2, Field3, Field4, Field5)++{-# DEPRECATED+    Lens+  , Lens'+  , Traversal+  , Traversal'+  , over+  , set+  , (%~)+  , (.~)+  , (^.)+  , (^..)+  , (^?)+  , _1+  , _2+  , _3+  , _4+  , _5+  , preuse+  , preview+  , use+  , view+  "Use corresponding function from 'lens' or 'microlens' package"+#-}++type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t+type Lens' s a = Lens s s a a++type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t+type Traversal' s a = Traversal s s a a++over :: Lens.Micro.ASetter s t a b -> (a -> b) -> s -> t+over = Lens.Micro.over++set :: Lens.Micro.ASetter s t a b -> b -> s -> t+set = Lens.Micro.set++(%~) :: Lens.Micro.ASetter s t a b -> (a -> b) -> s -> t+(%~) = (Lens.Micro.%~)++infixr 4 %~++(.~) :: Lens.Micro.ASetter s t a b -> b -> s -> t+(.~) = (Lens.Micro..~)++infixr 4 .~++(^.) :: s -> Lens.Micro.Getting a s a -> a+(^.) = (Lens.Micro.^.)++infixl 8 ^.++(^..) :: s -> Lens.Micro.Getting (Endo [a]) s a -> [a]+(^..) = (Lens.Micro.^..)++infixl 8 ^..++(^?) :: s -> Lens.Micro.Getting (First a) s a -> Maybe a+(^?) = (Lens.Micro.^?)++infixl 8 ^?++_1 :: Field1 s t a b => Lens s t a b+_1 = Lens.Micro._1++_2 :: Field2 s t a b => Lens s t a b+_2 = Lens.Micro._2++_3 :: Field3 s t a b => Lens s t a b+_3 = Lens.Micro._3++_4 :: Field4 s t a b => Lens s t a b+_4 = Lens.Micro._4++_5 :: Field5 s t a b => Lens s t a b+_5 = Lens.Micro._5++preuse :: MonadState s m => Lens.Micro.Getting (First a) s a -> m (Maybe a)+preuse = Lens.Micro.Mtl.preuse++preview :: MonadReader s m => Lens.Micro.Getting (First a) s a -> m (Maybe a)+preview = Lens.Micro.Mtl.preview++use :: MonadState s m => Lens.Micro.Getting a s a -> m a+use = Lens.Micro.Mtl.use++view :: MonadReader s m => Lens.Micro.Getting a s a -> m a+view = Lens.Micro.Mtl.view
src/Universum/Base.hs view
@@ -58,7 +58,7 @@  -- Base typeclasses import Data.Eq (Eq (..))-import Data.Foldable (Foldable, concat, concatMap, foldlM, foldrM)+import Data.Foldable (Foldable, concat, foldlM, foldrM) import Data.Kind (Constraint, Type) import Data.Ord (Down (..), Ord (..), Ordering (..), comparing) import Data.Traversable (Traversable (..), fmapDefault, foldMapDefault, forM, mapAccumL, mapAccumR)
src/Universum/Container/Class.hs view
@@ -39,6 +39,7 @@        , sequenceA_        , sequence_        , asum+       , concatMap           -- * Others        , One(..)@@ -46,7 +47,7 @@  import Data.Coerce (Coercible, coerce) import Data.Kind (Type)-import Prelude hiding (all, and, any, elem, foldMap, foldl, foldr, mapM_, notElem, null, or, print,+import Prelude hiding (all, and, any, concatMap, elem, foldMap, foldl, foldr, mapM_, notElem, null, or, print,                 product, sequence_, sum)  import Universum.Applicative (Alternative (..), Const, ZipList (..), pass)@@ -69,6 +70,8 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BSL +import qualified Data.List (concatMap)+ import qualified Data.Text as T import qualified Data.Text.Lazy as TL @@ -745,6 +748,16 @@     => t -> f a asum = foldr (<|>) empty {-# INLINE asum #-}++{- | Version of 'Data.Foldable.concatMap' constrained to 'Container'.++>>> concatMap (\x -> [x + 1, x + 2]) [1, 2, 3]+[2,3,3,4,4,5]++-}+concatMap :: Container c => (Element c -> [b]) -> c -> [b]+concatMap f = Data.List.concatMap f . toList+{-# INLINE concatMap #-}  ---------------------------------------------------------------------------- -- Disallowed instances
src/Universum/Exception.hs view
@@ -47,6 +47,7 @@ -- To suppress redundant applicative constraint warning on GHC 8.0 -- | Throws error for 'Maybe' if 'Data.Maybe.Nothing' is given. -- Operates over 'MonadError'.+{-# DEPRECATED note "Don't use this function. Use 'maybeToRight' instead" #-} note :: (MonadError e m) => e -> Maybe a -> m a note err = maybe (throwError err) pure 
src/Universum/Function.hs view
@@ -6,4 +6,4 @@        ( module Data.Function        ) where -import Data.Function (const, fix, flip, id, on, ($), (.))+import Data.Function (const, fix, flip, id, on, ($), (.), (&))
src/Universum/Functor/Reexport.hs view
@@ -12,6 +12,6 @@  import Control.Arrow ((&&&)) import Data.Bifunctor (Bifunctor (..))-import Data.Functor (Functor (..), void, ($>), (<$>))+import Data.Functor (Functor (..), void, ($>), (<$>), (<&>)) import Data.Functor.Compose (Compose (..)) import Data.Functor.Identity (Identity (..))
src/Universum/List/Reexport.hs view
@@ -9,10 +9,10 @@        ) where  import Data.List (break, cycle, drop, dropWhile, filter, genericDrop, genericLength,-                  genericReplicate, genericSplitAt, genericTake, group, inits, intercalate,+                  genericReplicate, genericSplitAt, genericTake, inits, intercalate,                   intersperse, isPrefixOf, iterate, permutations, repeat, replicate, reverse, scanl,                   scanr, sort, sortBy, sortOn, splitAt, subsequences, tails, take, takeWhile,                   transpose, unfoldr, unzip, unzip3, zip, zip3, zipWith, (++))-import Data.List.NonEmpty (NonEmpty (..), head, init, last, nonEmpty, tail)+import Data.List.NonEmpty (NonEmpty (..), group, groupAllWith, groupBy, groupWith, head, init, last, nonEmpty, tail)  import GHC.Exts (sortWith)
src/Universum/Monad/Reexport.hs view
@@ -57,7 +57,7 @@ import Control.Monad.Trans.Maybe (MaybeT (..), exceptToMaybeT, maybeToExceptT)  -- Maybe-import Data.Maybe (Maybe (..), catMaybes, fromMaybe, isJust, isNothing, listToMaybe, mapMaybe,+import Data.Maybe (Maybe (..), catMaybes, fromMaybe, isJust, isNothing, mapMaybe,                    maybe, maybeToList)  -- Either
src/Universum/Monoid.hs view
@@ -10,8 +10,8 @@  import Data.Monoid (All (..), Alt (..), Any (..), Dual (..), Endo (..), First (..), Last (..),                     Monoid (..), Product (..), Sum (..))-import Data.Semigroup (Option (..), Semigroup (sconcat, stimes, (<>)), WrappedMonoid, cycle1,-                       mtimesDefault, stimesIdempotent, stimesIdempotentMonoid, stimesMonoid)+import Data.Semigroup (Semigroup (sconcat, stimes, (<>)), WrappedMonoid, cycle1, mtimesDefault,+                       stimesIdempotent, stimesIdempotentMonoid, stimesMonoid)  import Universum.Monad.Reexport (Maybe, fromMaybe) 
src/Universum/String/Conversion.hs view
@@ -25,12 +25,14 @@           -- * Show and read functions        , readEither+       , readMaybe        , show        ) where  import Data.Bifunctor (first) import Data.Either (Either) import Data.Function (id, (.))+import Data.Maybe (Maybe) import Data.String (String) import qualified Data.Text.Internal as T import qualified Data.Text.Internal.Fusion.Common as TF@@ -47,7 +49,7 @@ import qualified Data.Text.Encoding.Error as T import qualified Data.Text.Lazy as LT import qualified Data.Text.Lazy.Encoding as LT-import qualified Text.Read (readEither)+import qualified Text.Read (readEither, readMaybe)  import qualified GHC.Show as Show (Show (show)) @@ -292,6 +294,15 @@ -- Left "Prelude.read: no parse" readEither :: (ToString a, Read b) => a -> Either Text b readEither = first toText . Text.Read.readEither . toString++-- | Polymorhpic version of 'Text.Read.readMaybe'.+--+-- >>> readMaybe @Int @Text "123"+-- Just 123+-- >>> readMaybe @Int @Text "aa"+-- Nothing+readMaybe :: forall b a. (ToString a, Read b) => a -> Maybe b+readMaybe = Text.Read.readMaybe . toString  -- | Generalized version of 'Prelude.show'. show :: forall b a . (Show.Show a, IsString b) => a -> b
src/Universum/String/Reexport.hs view
@@ -24,4 +24,4 @@ import Data.Text.Encoding.Error (OnDecodeError, OnError, UnicodeException, lenientDecode,                                  strictDecode) import Data.Text.Lazy (fromStrict, toStrict)-import Text.Read (Read, readMaybe, reads)+import Text.Read (Read, reads)
src/Universum/VarArg.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE FlexibleContexts       #-} {-# LANGUAGE FlexibleInstances      #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE MultiParamTypeClasses  #-}
+ test/Test/Universum/Issue208.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE+    GeneralizedNewtypeDeriving+  , UndecidableInstances+  , FlexibleContexts+  , GADTs+  , DerivingStrategies+  , CPP+#-}+module Test.Universum.Issue208+  () where++#if __GLASGOW_HASKELL__ >= 900++import Universum (Container)++-- In ghc-8.6.3 this code will produce a @redundant constraint@ warning.+-- In ghc-9.0.2 and newer no warnings would be produced.+-- Issue #208: https://github.com/serokell/universum/issues/208++newtype Test = Test [Int]+    deriving newtype (Container)++#endif
universum.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                universum-version:             1.7.3+version:             1.8.0 synopsis:            Custom prelude used in Serokell description:         See README.md file for more details. homepage:            https://github.com/serokell/universum@@ -13,11 +13,11 @@ stability:           stable build-type:          Simple bug-reports:         https://github.com/serokell/universum/issues-tested-with:         GHC == 8.4.4-                   , GHC == 8.6.5+tested-with:         GHC == 8.6.5                    , GHC == 8.8.4                    , GHC == 8.10.7                    , GHC == 9.0.1+                   , GHC == 9.2.2 extra-doc-files:     CHANGES.md                    , CONTRIBUTING.md                    , README.md@@ -43,6 +43,8 @@   if impl(ghc >= 8.10.1)     ghc-options:       -Wno-prepositive-qualified-module                        -Wno-inferred-safe-imports+  if impl(ghc >= 9.2.0)+    ghc-options:         -Wno-missing-kind-signatures    default-language:    Haskell2010 @@ -119,7 +121,9 @@   hs-source-dirs:      test   main-is:             Spec.hs -  other-modules:       Test.Universum.Property+  other-modules:+                       Test.Universum.Issue208+                       Test.Universum.Property    build-depends:       universum                      , bytestring@@ -147,6 +151,10 @@    if impl(ghc >= 8.10.1)     ghc-options:         -Wno-missing-safe-haskell-mode+  -- https://github.com/sol/doctest/issues/327+  -- TODO: re-enable when the issue is resolved+  if impl(ghc >= 9.0.0)+    buildable: False    ghc-options:         -threaded