packages feed

product-profunctors 0.9.0.0 → 0.10.0.0

raw patch · 6 files changed

+117/−80 lines, 6 filesdep ~contravariantdep ~profunctorsdep ~template-haskellPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: contravariant, profunctors, template-haskell

API changes (from Hackage documentation)

- Data.Profunctor.Product: (***<) :: ProductContravariant f => f a -> f b -> f (a, b)
- Data.Profunctor.Product: AndArrow :: arr z b -> AndArrow arr z a b
- Data.Profunctor.Product: PPOfContravariant :: (f a) -> PPOfContravariant f a b
- Data.Profunctor.Product: [runAndArrow] :: AndArrow arr z a b -> arr z b
- Data.Profunctor.Product: class Contravariant f => ProductContravariant f
- Data.Profunctor.Product: data AndArrow arr z a b
- Data.Profunctor.Product: defaultContravariantProduct :: (Contravariant f, Monoid (f (a, b))) => f a -> f b -> f (a, b)
- Data.Profunctor.Product: instance Control.Arrow.Arrow arr => Data.Profunctor.Product.Class.ProductProfunctor (Data.Profunctor.Product.AndArrow arr z)
- Data.Profunctor.Product: instance Control.Arrow.Arrow arr => Data.Profunctor.Unsafe.Profunctor (Data.Profunctor.Product.AndArrow arr z)
- Data.Profunctor.Product: instance Data.Functor.Contravariant.Contravariant f => Data.Profunctor.Unsafe.Profunctor (Data.Profunctor.Product.PPOfContravariant f)
- Data.Profunctor.Product: instance Data.Profunctor.Product.ProductContravariant f => Data.Profunctor.Product.Class.ProductProfunctor (Data.Profunctor.Product.PPOfContravariant f)
- Data.Profunctor.Product: newtype PPOfContravariant f a b
- Data.Profunctor.Product: point :: ProductContravariant f => f ()
- Data.Profunctor.Product: unPPOfContravariant :: PPOfContravariant c a a -> c a
- Data.Profunctor.Product.Default: cdef :: Default (PPOfContravariant u) a a => u a

Files

CHANGELOG.md view
@@ -1,3 +1,10 @@+# 0.10.0.0++* Removed `ProductContravariant`, `AndArrow`, `defaultContravariantProduct`,+  `PPOfContravariant`, `unPPOfContravariant`, `cdef`++* Deprecated `defaultEmpty`, `defaultProfunctorProduct`, `defaultPoint`+ # 0.9.0.0  * Added more `ProductProfunctor/SumProfunctor` instances including for
Data/Profunctor/Product.hs view
@@ -1,5 +1,27 @@ {-# LANGUAGE TemplateHaskell   #-} +-- | If @p@ is an instance of 'ProductProfunctor' then @p a a'@+-- represents a sort of process for turning @a@s into @a'@s that can+-- be "laid out side-by-side" with other values of @p@ to form "wider"+-- processes.  For example, if I have+--+-- @+-- a :: p a a' -- a process for turning as into a's+-- b :: p b b' -- a process for turning bs into b's+-- c :: p c c' -- a process for turning cs into c's+-- @+--+-- then I can combine them using 'p3' to get+--+-- @+-- p3 a b c :: p (a, b, c) (a', b', c')+-- -- a process for turning (a, b, c)s into (a', b', c')s+-- @+--+-- You would typically compose 'ProductProfunctor's using+-- 'Profunctors''s 'Profunctor.lmap' and 'Applicative''s 'pure',+-- '<$>' / 'fmap' and '<*>'.+ module Data.Profunctor.Product (module Data.Profunctor.Product.Class,                                 module Data.Profunctor.Product.Newtype,                                 module Data.Profunctor.Product) where@@ -79,9 +101,8 @@ -- -- '***$' = 'Profunctor.rmap', just like '<$>' = 'fmap'. ----- You will probably never need to use this; @\<$\>@ should be--- sufficient (if your 'ProductProfunctor' instance has also been given--- a @Functor@ instance).+-- (You probably won't need to use this.  @\<$\>@ should be+-- sufficient.) (***$) :: ProductProfunctor p => (b -> c) -> p a b -> p a c (***$) = Profunctor.rmap @@ -179,54 +200,17 @@  -- { Deprecated stuff --- | You probably never want to use 'defaultEmpty' and it may be--- deprecated in a later version.+{-# DEPRECATED defaultEmpty "Use pure () instead" #-} defaultEmpty :: Applicative (p ()) => p () () defaultEmpty = pure () --- | You probably never want to use 'defaultProfunctorProduct' and it--- may be deprecated in a later version.+{-# DEPRECATED defaultProfunctorProduct "Use \\p p' -> liftA2 (,) (lmap fst p) (lmap snd p') instead" #-} defaultProfunctorProduct :: (Applicative (p (a, a')), Profunctor p)                          => p a b -> p a' b' -> p (a, a') (b, b') defaultProfunctorProduct p p' = liftA2 (,) (lmap fst p) (lmap snd p') --- | You probably never want to use 'defaultPoint' and it may be--- deprecated in a later version.+{-# DEPRECATED defaultPoint "Use mempty instead" #-} defaultPoint :: Monoid (p ()) => p () defaultPoint = mempty--{-# DEPRECATED ProductContravariant "Use Data.Functor.Contravariant.Divisible instead" #-}-class Contravariant f => ProductContravariant f where-  point  :: f ()-  (***<) :: f a -> f b -> f (a, b)--{-# DEPRECATED AndArrow "If you really need this, file an issue. It will go soon." #-}-data AndArrow arr z a b = AndArrow { runAndArrow :: arr z b }--instance Arrow arr => Profunctor (AndArrow arr z) where-  dimap _ f (AndArrow g) = AndArrow (arr f <<< g)--instance Arrow arr => ProductProfunctor (AndArrow arr z) where-  empty = AndArrow (arr (const ()))-  (AndArrow f) ***! (AndArrow f') = AndArrow (f &&& f')--{-# DEPRECATED defaultContravariantProduct "defaultContravariantProduct will be removed" #-}-defaultContravariantProduct :: (Contravariant f, Monoid (f (a, b)))-                            => f a -> f b -> f (a, b)-defaultContravariantProduct p p' = contramap fst p <> contramap snd p'--{-# DEPRECATED PPOfContravariant "PPOfContravariant will be removed" #-}-newtype PPOfContravariant f a b = PPOfContravariant (f a)--{-# DEPRECATED unPPOfContravariant "unPPOfContravariant will be removed" #-}-unPPOfContravariant :: PPOfContravariant c a a -> c a-unPPOfContravariant (PPOfContravariant pp) = pp--instance Contravariant f => Profunctor (PPOfContravariant f) where-  dimap f _ (PPOfContravariant p) = PPOfContravariant (contramap f p)--instance ProductContravariant f => ProductProfunctor (PPOfContravariant f) where-  empty = PPOfContravariant point-  PPOfContravariant f ***! PPOfContravariant f' = PPOfContravariant (f ***< f')  -- }
Data/Profunctor/Product/Class.hs view
@@ -3,31 +3,41 @@ import           Data.Profunctor (Profunctor) import qualified Data.Profunctor as Profunctor --- | 'ProductProfunctor' is a generalization of 'Applicative'.+--- vv These are redundant imports but they're needeed for Haddock+--- links. AIUI Haddock can't link to something you haven't imported. ----- It has the usual 'Applicative' "output" (covariant) parameter on--- the right.  Additionally it has an "input" (contravariant) type--- parameter on the left.+--     https://github.com/haskell/haddock/issues/796+import qualified Control.Applicative+import qualified Data.Profunctor++-- | 'ProductProfunctor' is a generalization of+-- 'Control.Applicative.Applicative'.+-- It has the usual 'Control.Applicative.Applicative' "output"+-- (covariant) parameter on the right.  Additionally it has an "input"+-- (contravariant) type parameter on the left. ----- You will find it easier to see the correspondence between--- 'ProductProfunctor' and 'Applicative' if you look at @purePP@,--- @(***$)@, and @(****)@, which correspond to @pure@, @(\<$\>)@, and--- @(\<*\>)@ respectively.+-- The methods for 'ProductProfunctor' correspond closely to those for+-- 'Control.Applicative.Applicative' as laid out in the following+-- table.+-- The only difference between them is that the 'ProductProfunctor'+-- has a contravariant type parameter on the left.  We can use the+-- contravariant to compose them in nice ways as described at+-- "Data.Profunctor.Product". -- -- @ -- | Correspondence between Applicative and ProductProfunctor -- |--- |  Applicative f           ProductProfunctor p+-- |  'Control.Applicative.Applicative' f           'ProductProfunctor' p -- |--- |  pure                    purePP+-- |  'Control.Applicative.pure'                    'purePP' -- |    :: b -> f b             :: b -> p a b -- |--- |  (\<$\>)                   (***$)+-- |  ('Control.Applicative.<$>')                   ('Data.Profunctor.Product.***$') -- |    :: (b -> b')            :: (b -> b') -- |    -> f b                  -> p a b -- |    -> f b'                 -> p a b' -- |--- |  (\<*\>)                   (****)+-- |  ('Control.Applicative.<*>')                   ('****') -- |    :: f (b -> b')          :: p a (b -> b') -- |    -> f b                  -> p a b -- |    -> f b'                 -> p a b'@@ -37,47 +47,49 @@ -- instances -- -- @---  instance Profunctor MyProductProfunctor where+--  instance 'Profunctor' MyProductProfunctor where --    ... -----  instance Applicative (MyProductProfunctor a) where+--  instance 'Control.Applicative.Applicative' (MyProductProfunctor a) where --    ... -- @ -- -- and then write -- -- @---  instance ProductProfunctor MyProductProfunctor where---    purePP = pure---    (****) = (\<*\>)+--  instance 'ProductProfunctor' MyProductProfunctor where+--    'purePP' = 'Control.Applicative.pure'+--    ('****') = ('Control.Applicative.<*>') -- @ class Profunctor p => ProductProfunctor p where-  -- | 'purePP' is the generalisation of @Applicative@'s @pure@.+  -- | 'purePP' is the generalisation of @Applicative@'s+  -- 'Control.Applicative.pure'.   ---  -- Aside from defining 'ProductProfunctor' instances you will-  -- probably never need to use this; @pure@ should be sufficient (if-  -- your 'ProductProfunctor' instance also has an @Applicative@-  -- instance).+  -- (You probably won't need to use this except to define+  -- 'ProductProfunctor' instances.  In your own code @pure@ should be+  -- sufficient.)   purePP :: b -> p a b   purePP b = Profunctor.dimap (const ()) (const b) empty -  -- | '****' is the generalisation of @Applicative@'s @\<*\>@.+  -- | '****' is the generalisation of @Applicative@'s+  -- 'Control.Applicative.<*>'.   ---  -- Aside from defining 'ProductProfunctor' instances you will you-  -- will probably never need to use this; @\<*\>@ should be-  -- sufficient (if your 'ProductProfunctor' instance has also been-  -- given an @Applicative@ instance).+  -- (You probably won't need to use this except to define+  -- 'ProductProfunctor' instances.  In your own code @\<*\>@ should+  -- be sufficient.)   (****) :: p a (b -> c) -> p a b -> p a c   (****) f x = Profunctor.dimap dup (uncurry ($)) (f ***! x)     where dup y = (y, y) -  -- | You probably never want to use 'empty' and it may be deprecated-  -- in a future version.+  -- | Use @pure ()@ instead.  @empty@ may be deprecated in a future+  -- version.   empty  :: p () ()   empty = purePP () -  -- | You probably never want to use '***!' and it may be-  -- deprecated in a future version.+  -- | Use @\\f g -> (,) 'Control.Applicative.<$>'+  -- 'Data.Profunctor.lmap' fst f 'Control.Applicative.<*>'+  -- 'Data.Profunctor.lmap' snd g@ instead.+  -- @(***!)@ may be deprecated in a future version.   (***!) :: p a b -> p a' b' -> p (a, a') (b, b')   f ***! g = (,) `Profunctor.rmap` Profunctor.lmap fst f                   **** Profunctor.lmap snd g
Data/Profunctor/Product/Default.hs view
@@ -2,6 +2,44 @@ {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances,              FlexibleContexts, PolyKinds, TemplateHaskell #-} +-- | For some 'Data.Profunctor.Product.ProductProfunctor's @p@ and+-- types @a@, @a'@ there is a unique most sensible value of @p a a'@.+-- 'Default' exists to automatically generate that unique most+-- sensible value for a product given unique most sensible values for+-- the base types. If the unique most sensible values of type @p a+-- a'@, @p b b'@ and @p c c'@ are+--+-- @+-- sensible_a :: p a a'+-- sensible_b :: p b b'+-- sensible_c :: p c c'+-- @+--+-- then the unique most sensible value of type @p (a, b, c) (a', b',+-- c')@ is+--+-- @+--'Data.Profunctor.Product.p3' (sensible_a, sebsible_b, sensible_c)+--     :: p (a, b, c) (a', b', c')+-- @+--+-- Therefore there is an instance+--+-- @+-- instance+--   ( 'Default' p a a'+--   , 'Default' p b b'+--   , 'Default' p c c'+--   )+-- => 'Default' p (a, b, c) (a', b', c')+--     where 'def' = 'Data.Profunctor.Product.p3' ('def', 'def', 'def')+-- @+--+-- which can be read as "if the unique most sensible values of types+-- ... are ... then the unique most sensible value of the 3-tuple is+-- given by composing them with 'p3'".  Naturally each different+-- product type has a different composition function.+ module Data.Profunctor.Product.Default   ( module Data.Profunctor.Product.Default   , module Data.Profunctor.Product.Default.Class@@ -16,10 +54,6 @@  import Data.Profunctor.Product.Default.Class import Data.Profunctor.Product.Tuples.TH (mkDefaultNs, maxTupleSize)---- | This will be deprecated in a future version-cdef :: Default (PPOfContravariant u) a a => u a-cdef = unPPOfContravariant def  instance (Profunctor p, Default p a b) => Default p (Identity a) (Identity b)   where
README.md view
@@ -1,4 +1,4 @@-# product-profunctors [![Hackage version](https://img.shields.io/hackage/v/product-profunctors.svg?label=Hackage)](https://hackage.haskell.org/package/product-profunctors) [![Linux Build Status](https://img.shields.io/travis/tomjaguarpaw/product-profunctors.svg?label=Linux%20build)](https://travis-ci.org/tomjaguarpaw/product-profunctors)+# product-profunctors [![Hackage version](https://img.shields.io/hackage/v/product-profunctors.svg?label=Hackage)](https://hackage.haskell.org/package/product-profunctors) [![Linux Build Status](https://img.shields.io/travis/tomjaguarpaw/product-profunctors/master.svg?label=Linux%20build)](https://travis-ci.org/tomjaguarpaw/product-profunctors)  ## Backup maintainers 
product-profunctors.cabal view
@@ -1,6 +1,6 @@ name:          product-profunctors copyright:     Copyright (c) 2013, Karamaan Group LLC; 2014-2018 Purely Agile Limited-version:       0.9.0.0+version:       0.10.0.0 synopsis:      product-profunctors description:   Product profunctors homepage:      https://github.com/tomjaguarpaw/product-profunctors