packages feed

witherable 0.3 → 0.3.1

raw patch · 3 files changed

+77/−16 lines, 3 files

Files

+ CHANGELOG.md view
@@ -0,0 +1,46 @@+0.3.1+-------+* Added `(<$?>)` as an alias for `mapMaybe`, with fixity matching `(<$>)`.+* Added `(<&?>) = flip (<$?>)`, with fixity matching `(<&>)`.++0.3+-------+* Added `(Filterable f, Filterable g) => Filterable (Product f g)`+* Added `(Witherable f, Witherable g) => Witherable (Product f g)`+* Added `(Filterable f, Filterable g) => Filterable (Sum f g)`+* Added `(Witherable f, Witherable g) => Witherable (Sum f g)`+* Added `Filterable f => Filterable (IdentityT f)`+* Added `Witherable f => Witherable (IdentityT f)`+* Switched from strict `HashMap` operations to lazy ones. This+  matches the behavior of the rest of the instances.+* Changed the definition of `witherM`++0.2+-------+* Added `Traversable t => Witherable (MaybeT t)`+* New class: `Filterable`+  * `Witherable t` is equivalent to `(Traversable t, Filterable t)`+* Removed `Chipped`++0.1.3.3+-------+* Added `forMaybeOf` and `forMaybe`++0.1.3.2+-------+* Exported `witherM`, `blightM`+* Fixed the default definition of `catMaybes`++0.1.3+-------+* Now `witherable` depends on `base-orphans` to prevent a tragedy of duplicate orphans+* Added generalized combinators according to the `lens` convention++0.1.2.3+-------+* Added `ordNub`, `hashNub`+* Data.Witherable is now Trustworthy++0.1.2.2+-------+* Added `Chipped`
src/Data/Witherable.hs view
@@ -16,6 +16,8 @@ ----------------------------------------------------------------------------- module Data.Witherable   ( Filterable(..)+  , (<$?>)+  , (<&?>)   , Witherable(..)   , ordNub   , hashNub@@ -60,9 +62,7 @@ #if (MIN_VERSION_base(4,7,0)) import Data.Proxy #endif-#if __GLASGOW_HASKELL__ >= 708 import Data.Coerce (coerce)-#endif import Prelude -- Fix redundant import warning  -- | This type allows combinators to take a 'Filter' specializing the parameter @f@.@@ -141,15 +141,12 @@ filterOf w f = runIdentity . filterAOf w (idDot f) {-# INLINE filterOf #-} --- | Like 'Functor', but it include 'Maybe' effects.+-- | Like 'Functor', but you can remove elements instead of updating them. -- -- Formally, the class 'Filterable' represents a functor from @Kleisli Maybe@ to @Hask@. -- -- A definition of 'mapMaybe' must satisfy the following laws: ----- [/identity/]---   @'mapMaybe' Just ≡ id@--- -- [/conservation/] --   @'mapMaybe' (Just . f) ≡ 'fmap' f@ --@@ -175,13 +172,30 @@   {-# MINIMAL mapMaybe | catMaybes #-} #endif --- | Like 'Traversable', but you can remove elements instead of updating them.+-- | An infix alias for 'mapMaybe'. The name of the operator alludes+-- to '<$>', and has the same fixity. ----- A definition of 'wither' must satisfy the following laws:+-- @since 0.3.1+(<$?>) :: Filterable f => (a -> Maybe b) -> f a -> f b+(<$?>) = mapMaybe+infixl 4 <$?>++-- | Flipped version of '<$?>', the 'Filterable' version of+-- 'Data.Functor.<&>'. It has the same fixity as 'Data.Functor.<&>'. ----- [/identity/]---   @'wither' ('pure' . Just) ≡ 'pure'@+-- @+-- ('<&?>') = 'flip' 'mapMaybe'+-- @ --+-- @since 0.3.1+(<&?>) :: Filterable f => f a -> (a -> Maybe b) -> f b+as <&?> f = mapMaybe f as+infixl 1 <&?>++-- | An enhancement of 'Traversable' with 'Filterable'+--+-- A definition of 'wither' must satisfy the following laws:+-- -- [/conservation/] --   @'wither' ('fmap' 'Just' . f) ≡ 'traverse' f@ --@@ -195,7 +209,9 @@  class (T.Traversable t, Filterable t) => Witherable t where -  -- | @'traverse' f ≡ 'wither' ('fmap' 'Just' . f)@+  -- | Effectful 'mapMaybe'.+  --+  -- @'wither' ('pure' . f) ≡ 'pure' . 'mapMaybe' f@   wither :: Applicative f => (a -> f (Maybe b)) -> t a -> f (t b)   wither f = fmap catMaybes . T.traverse f   {-# INLINE wither #-}@@ -211,7 +227,6 @@ #endif   {-# INLINE witherM #-} -  -- | @'Compose' . 'fmap' ('filterA' f) . 'filterA' g ≡ 'filterA' (\x -> 'Compose' $ 'fmap' (\b -> (b&&) <$> f x) (g x)@   filterA :: Applicative f => (a -> f Bool) -> t a -> f (t a)   filterA = filterAOf wither 
witherable.cabal view
@@ -1,5 +1,5 @@ name:                witherable-version:             0.3+version:             0.3.1 synopsis:            filterable traversable description:         A stronger variant of `traverse` which can remove elements and generalised mapMaybe, catMaybes, filter homepage:            https://github.com/fumieval/witherable@@ -10,9 +10,9 @@ copyright:           Copyright (c) 2014 Fumiaki Kinoshita category:            Data build-type:          Simple--- extra-source-files:+extra-source-files:  CHANGELOG.md cabal-version:       >=1.10-tested-With: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3+tested-With: GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.3  source-repository head   type: git@@ -31,5 +31,5 @@                        unordered-containers,                        vector   hs-source-dirs:      src-  ghc-options:         -Wall+  ghc-options:         -Wall -Wcompat   default-language:    Haskell2010