packages feed

barbies 1.1.2.0 → 1.1.2.1

raw patch · 6 files changed

+30/−8 lines, 6 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Data.Barbie: btraverseC :: forall c b f g h. (TraversableB b, ConstraintsB b, AllB c b, Applicative g) => (forall a. c a => f a -> g (h a)) -> b f -> g (b h)
+ Data.Barbie.Constraints: btraverseC :: forall c b f g h. (TraversableB b, ConstraintsB b, AllB c b, Applicative g) => (forall a. c a => f a -> g (h a)) -> b f -> g (b h)

Files

ChangeLog.md view
@@ -1,5 +1,8 @@ # Changelog for barbies +## 1.1.2.1+  - Uploaded 1.1.2.0 was broken (missing `btraverseC`)+ ## 1.1.2.0   - Add `traverseC` (Ole Krüger).   - Fix typo in ProductB laws (thanks to Ben Radford).
barbies.cabal view
@@ -1,5 +1,5 @@ name:           barbies-version:        1.1.2.0+version:        1.1.2.1 synopsis:       Classes for working with types that can change clothes. description:    Types that are parametric on a functor are like Barbies that have an outfit for each role. This package provides the basic abstractions to work with them comfortably. category:       Data-structures
src/Data/Barbie.hs view
@@ -82,6 +82,7 @@   , AllBF     -- ** Utility functions   , bmapC+  , btraverseC      -- * Products and constaints   , ProductBC(bdicts)@@ -108,7 +109,7 @@  where -import Data.Barbie.Internal.Constraints(ConstraintsB(..), AllBF, bmapC)+import           Data.Barbie.Internal.Constraints (AllBF, ConstraintsB (..), bmapC, btraverseC) import qualified Data.Barbie.Internal.Constraints as Deprecated  import Data.Barbie.Internal.Functor(FunctorB(..))
src/Data/Barbie/Constraints.hs view
@@ -31,6 +31,7 @@   , ConstraintsB(..)   , ProductBC(..)   , bmapC+  , btraverseC    , AllBF   , ClassF
src/Data/Barbie/Internal/Constraints.hs view
@@ -5,6 +5,7 @@ module Data.Barbie.Internal.Constraints   ( ConstraintsB(..)   , bmapC+  , btraverseC   , AllBF    , CanDeriveConstraintsB@@ -21,8 +22,9 @@  where -import Data.Barbie.Internal.Dicts   (ClassF, Dict (..), requiringDict)-import Data.Barbie.Internal.Functor (FunctorB (..))+import Data.Barbie.Internal.Dicts       (ClassF, Dict (..), requiringDict)+import Data.Barbie.Internal.Functor     (FunctorB (..))+import Data.Barbie.Internal.Traversable (TraversableB (..))  import Data.Functor.Compose (Compose (..)) import Data.Functor.Const   (Const (..))@@ -109,6 +111,14 @@     go :: forall a. (Dict c `Product` f) a -> g a     go (d `Pair` fa) = requiringDict (f fa) d +-- | Like 'btraverse' but with a constraint on the elements of @b@.+btraverseC+  :: forall c b f g h+  .  (TraversableB b, ConstraintsB b, AllB c b, Applicative g)+  => (forall a. c a => f a -> g (h a))+  -> b f+  -> g (b h)+btraverseC f b = btraverse (\(Pair (Dict :: Dict c a) x) -> f x) (baddDicts b)  -- | Similar to 'AllB' but will put the functor argument @f@ --   between the constraint @c@ and the type @a@. For example:
test/Spec.hs view
@@ -11,10 +11,11 @@ import Barbies import BarbiesW -import Data.Barbie (bfoldMap, bmapC, buniqC)-import Data.Barbie.Bare(Covered)-import Data.Functor.Const(Const(..))-import Data.Functor.Identity(Identity(..))+import Data.Barbie           (bfoldMap, bmapC, btraverseC, buniqC)+import Data.Barbie.Bare      (Covered)+import Data.Functor.Const    (Const (..))+import Data.Functor.Identity (Identity (..))+import Data.Monoid           (Sum (..))  main :: IO () main@@ -187,6 +188,12 @@           [ testCase "Record1" $                 bmapC @Num (fmap (+1)) (Record1 (Identity 0))                     @?= Record1 (Identity 1)+          ]+        , testGroup+          "btraverseC"+          [ testCase "Record1" $+                btraverseC @Num (\inner -> (Sum @Int 1, fmap (+ 1) inner)) (Record1 (Identity 0))+                    @?= (Sum 1, Record1 (Identity 1))           ]         , testGroup           "buniqC"