packages feed

profunctors 4.3.2 → 4.4

raw patch · 5 files changed

+65/−5 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Profunctor.Rep: firstRep :: Representable p => p a b -> p (a, c) (b, c)
+ Data.Profunctor.Rep: secondRep :: Representable p => p a b -> p (c, a) (c, b)
- Data.Profunctor.Rep: class (Functor (Rep p), Profunctor p) => Representable p where type family Rep p :: * -> *
+ Data.Profunctor.Rep: class (Functor (Rep p), Strong p) => Representable p where type family Rep p :: * -> *
- Data.Profunctor.Unsafe: (#.) :: Profunctor p => (b -> c) -> p a b -> p a c
+ Data.Profunctor.Unsafe: (#.) :: (Profunctor p, Coercible c b) => (b -> c) -> p a b -> p a c
- Data.Profunctor.Unsafe: (.#) :: Profunctor p => p b c -> (a -> b) -> p a c
+ Data.Profunctor.Unsafe: (.#) :: (Profunctor p, Coercible b a) => p b c -> (a -> b) -> p a c

Files

CHANGELOG.markdown view
@@ -1,3 +1,9 @@+4.4+-----+* Added `Coercible` constraint to (#.) and (.#) when building with GHC 7.8+* `Strong` is now a superclass of `Representable`+* Updated the URL of the "Arrows are Strong Monads" paper. The old URL is now a dead link.+ 4.3.2 ----- * Added some missing instances for `UpStar` and `DownStar`.
profunctors.cabal view
@@ -1,6 +1,6 @@ name:          profunctors category:      Control, Categories-version:       4.3.2+version:       4.4 license:       BSD3 cabal-version: >= 1.10 license-file:  LICENSE
src/Data/Profunctor.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-} #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} #endif@@ -54,7 +55,12 @@ import Data.Tuple import Data.Profunctor.Unsafe import Prelude hiding (id,(.),sequence)++#if __GLASGOW_HASKELL__ >= 708+import Data.Coerce+#else import Unsafe.Coerce+#endif  infixr 0 :-> type p :-> q = forall a b. p a b -> q a b@@ -74,7 +80,11 @@   rmap k (UpStar f) = UpStar (fmap k . f)   {-# INLINE rmap #-}   -- We cannot safely overload ( #. ) because we didn't write the 'Functor'.+#if __GLASGOW_HASKELL__ >= 708+  p .# _ = coerce p+#else   p .# _ = unsafeCoerce p+#endif   {-# INLINE ( .# ) #-}  instance Functor f => Functor (UpStar f a) where@@ -115,7 +125,11 @@   {-# INLINE lmap #-}   rmap k (DownStar f) = DownStar (k . f)   {-# INLINE rmap #-}+#if __GLASGOW_HASKELL__ >= 708+  ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+#else   ( #. ) _ = unsafeCoerce+#endif   {-# INLINE ( #. ) #-}   -- We cannot overload ( .# ) because we didn't write the 'Functor'. @@ -226,7 +240,7 @@ -- This describes profunctor strength with respect to the product structure -- of Hask. ----- <http://takeichi.ipl-lab.org/~asada/papers/arrStrMnd.pdf>+-- <http://www-kb.is.s.u-tokyo.ac.jp/~asada/papers/arrStrMnd.pdf> class Profunctor p => Strong p where   first' :: p a b  -> p (a, c) (b, c)   first' = dimap swap swap . second'
src/Data/Profunctor/Rep.hs view
@@ -10,7 +10,7 @@ ----------------------------------------------------------------------------- -- | -- Module      :  Data.Profunctor.Rep--- Copyright   :  (C) 2011-2012 Edward Kmett,+-- Copyright   :  (C) 2011-2015 Edward Kmett, -- License     :  BSD-style (see the file LICENSE) -- -- Maintainer  :  Edward Kmett <ekmett@gmail.com>@@ -22,6 +22,7 @@   (   -- * Representable Profunctors     Representable(..), tabulated+  , firstRep, secondRep   -- * Corepresentable Profunctors   , Corepresentable(..), cotabulated   ) where@@ -38,10 +39,18 @@  -- | A 'Profunctor' @p@ is 'Representable' if there exists a 'Functor' @f@ such that -- @p d c@ is isomorphic to @d -> f c@.-class (Functor (Rep p), Profunctor p) => Representable p where+class (Functor (Rep p), Strong p) => Representable p where   type Rep p :: * -> *   tabulate :: (d -> Rep p c) -> p d c   rep :: p d c -> d -> Rep p c++-- | Default definition for 'first'' given that p is 'Representable'.+firstRep :: Representable p => p a b -> p (a, c) (b, c)+firstRep p = tabulate $ \(a,c) -> (\b -> (b, c)) <$> rep p a++-- | Default definition for 'second'' given that p is 'Representable'.+secondRep :: Representable p => p a b -> p (c, a) (c, b)+secondRep p = tabulate $ \(c,a) -> (,) c <$> rep p a  instance Representable (->) where   type Rep (->) = Identity
src/Data/Profunctor/Unsafe.hs view
@@ -2,6 +2,7 @@ #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Unsafe #-} #endif+{-# LANGUAGE ScopedTypeVariables #-} ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2013 Edward Kmett@@ -37,7 +38,12 @@ import Control.Monad (liftM) import Data.Tagged import Prelude hiding (id,(.),sequence)++#if __GLASGOW_HASKELL__ >= 708+import Data.Coerce+#else import Unsafe.Coerce+#endif  {-# ANN module "Hlint: ignore Redundant lambda" #-} {-# ANN module "Hlint: ignore Collapse lambdas" #-}@@ -127,7 +133,11 @@   -- should match the default definition:   --   -- @('Profuctor.Unsafe.#.') ≡ \\f -> \\p -> p \`seq\` 'rmap' f p@+#if __GLASGOW_HASKELL__ >= 708+  ( #. ) :: Coercible c b => (b -> c) -> p a b -> p a c+#else   ( #. ) :: (b -> c) -> p a b -> p a c+#endif   ( #. ) = \f -> \p -> p `seq` rmap f p   {-# INLINE ( #. ) #-} @@ -153,7 +163,11 @@   -- operationally identity.   --   -- @('.#') ≡ \\p -> p \`seq\` \\f -> 'lmap' f p@+#if __GLASGOW_HASKELL__ >= 708+  ( .# ) :: Coercible b a => p b c -> (a -> b) -> p a c+#else   ( .# ) :: p b c -> (a -> b) -> p a c+#endif   ( .# ) = \p -> p `seq` \f -> lmap f p   {-# INLINE ( .# ) #-} @@ -168,9 +182,14 @@   {-# INLINE lmap #-}   rmap = (.)   {-# INLINE rmap #-}+#if __GLASGOW_HASKELL__ >= 708+  ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+  ( .# ) pbc _ = coerce pbc+#else   ( #. ) _ = unsafeCoerce-  {-# INLINE ( #. ) #-}   ( .# ) pbc _ = unsafeCoerce pbc+#endif+  {-# INLINE ( #. ) #-}   {-# INLINE ( .# ) #-}  instance Profunctor Tagged where@@ -180,7 +199,11 @@   {-# INLINE lmap #-}   rmap = fmap   {-# INLINE rmap #-}+#if __GLASGOW_HASKELL__ >= 708+  ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+#else   ( #. ) _ = unsafeCoerce+#endif   {-# INLINE ( #. ) #-}   Tagged s .# _ = Tagged s   {-# INLINE ( .# ) #-}@@ -193,7 +216,11 @@   rmap k (Kleisli f) = Kleisli (liftM k . f)   {-# INLINE rmap #-}   -- We cannot safely overload (#.) because we didn't provide the 'Monad'.+#if __GLASGOW_HASKELL__ >= 708+  ( .# ) pbc _ = coerce pbc+#else   ( .# ) pbc _ = unsafeCoerce pbc+#endif   {-# INLINE ( .# ) #-}  instance Functor w => Profunctor (Cokleisli w) where@@ -204,5 +231,9 @@   rmap k (Cokleisli f) = Cokleisli (k . f)   {-# INLINE rmap #-}   -- We cannot safely overload (.#) because we didn't provide the 'Functor'.+#if __GLASGOW_HASKELL__ >= 708+  ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+#else   ( #. ) _ = unsafeCoerce+#endif   {-# INLINE ( #. ) #-}