{-# LANGUAGE CPP #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Data.Profunctor.Unsafe
(
Profunctor(..)
) where
import Control.Arrow
import Control.Category
import Control.Comonad (Cokleisli(..))
import Control.Monad (liftM)
import Data.Bifunctor.Biff (Biff(..))
import Data.Bifunctor.Clown (Clown(..))
import Data.Bifunctor.Joker (Joker(..))
import Data.Bifunctor.Product (Product(..))
import Data.Bifunctor.Sum (Sum(..))
import Data.Bifunctor.Tannen (Tannen(..))
import Data.Coerce (Coercible, coerce)
#if __GLASGOW_HASKELL__ < 710
import Data.Functor
#endif
import Data.Functor.Contravariant (Contravariant(..))
import Data.Tagged
import Prelude hiding (id,(.))
infixr 9 #.
infixl 8 .#
class Profunctor p where
dimap :: (a -> b) -> (c -> d) -> p b c -> p a d
dimap a -> b
f c -> d
g = forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap a -> b
f forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap c -> d
g
{-# INLINE dimap #-}
lmap :: (a -> b) -> p b c -> p a c
lmap a -> b
f = forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap a -> b
f forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
{-# INLINE lmap #-}
rmap :: (b -> c) -> p a b -> p a c
rmap = forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
{-# INLINE rmap #-}
(#.) :: forall a b c q. Coercible c b => q b c -> p a b -> p a c
(#.) = \q b c
_ -> \p a b
p -> p a b
p seq :: forall a b. a -> b -> b
`seq` forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (coerce :: forall a b. Coercible a b => a -> b
coerce (forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id :: c -> c) :: b -> c) p a b
p
{-# INLINE (#.) #-}
(.#) :: forall a b c q. Coercible b a => p b c -> q a b -> p a c
(.#) = \p b c
p -> p b c
p seq :: forall a b. a -> b -> b
`seq` \q a b
_ -> forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap (coerce :: forall a b. Coercible a b => a -> b
coerce (forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id :: b -> b) :: a -> b) p b c
p
{-# INLINE (.#) #-}
{-# MINIMAL dimap | (lmap, rmap) #-}
instance Profunctor (->) where
dimap :: forall a b c d. (a -> b) -> (c -> d) -> (b -> c) -> a -> d
dimap a -> b
ab c -> d
cd b -> c
bc = c -> d
cd forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> c
bc forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> b
ab
{-# INLINE dimap #-}
lmap :: forall a b c. (a -> b) -> (b -> c) -> a -> c
lmap = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
(.)
{-# INLINE lmap #-}
rmap :: forall b c a. (b -> c) -> (a -> b) -> a -> c
rmap = forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
(.)
{-# INLINE rmap #-}
#. :: forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
(#.) q b c
_ = coerce :: forall a b. Coercible a b => a -> b
coerce (\b
x -> b
x :: b) :: forall a b. Coercible b a => a -> b
.# :: forall a b c (q :: * -> * -> *).
Coercible b a =>
(b -> c) -> q a b -> a -> c
(.#) b -> c
pbc q a b
_ = coerce :: forall a b. Coercible a b => a -> b
coerce b -> c
pbc
{-# INLINE (#.) #-}
{-# INLINE (.#) #-}
instance Profunctor Tagged where
dimap :: forall a b c d. (a -> b) -> (c -> d) -> Tagged b c -> Tagged a d
dimap a -> b
_ c -> d
f (Tagged c
s) = forall {k} (s :: k) b. b -> Tagged s b
Tagged (c -> d
f c
s)
{-# INLINE dimap #-}
lmap :: forall a b c. (a -> b) -> Tagged b c -> Tagged a c
lmap a -> b
_ = forall {k1} {k2} (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag
{-# INLINE lmap #-}
rmap :: forall b c a. (b -> c) -> Tagged a b -> Tagged a c
rmap = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
{-# INLINE rmap #-}
#. :: forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Tagged a b -> Tagged a c
(#.) q b c
_ = coerce :: forall a b. Coercible a b => a -> b
coerce (\b
x -> b
x :: b) :: forall a b. Coercible b a => a -> b
{-# INLINE (#.) #-}
Tagged c
s .# :: forall a b c (q :: * -> * -> *).
Coercible b a =>
Tagged b c -> q a b -> Tagged a c
.# q a b
_ = forall {k} (s :: k) b. b -> Tagged s b
Tagged c
s
{-# INLINE (.#) #-}
instance Monad m => Profunctor (Kleisli m) where
dimap :: forall a b c d.
(a -> b) -> (c -> d) -> Kleisli m b c -> Kleisli m a d
dimap a -> b
f c -> d
g (Kleisli b -> m c
h) = forall (m :: * -> *) a b. (a -> m b) -> Kleisli m a b
Kleisli (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM c -> d
g forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> m c
h forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> b
f)
{-# INLINE dimap #-}
lmap :: forall a b c. (a -> b) -> Kleisli m b c -> Kleisli m a c
lmap a -> b
k (Kleisli b -> m c
f) = forall (m :: * -> *) a b. (a -> m b) -> Kleisli m a b
Kleisli (b -> m c
f forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> b
k)
{-# INLINE lmap #-}
rmap :: forall b c a. (b -> c) -> Kleisli m a b -> Kleisli m a c
rmap b -> c
k (Kleisli a -> m b
f) = forall (m :: * -> *) a b. (a -> m b) -> Kleisli m a b
Kleisli (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM b -> c
k forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> m b
f)
{-# INLINE rmap #-}
.# :: forall a b c (q :: * -> * -> *).
Coercible b a =>
Kleisli m b c -> q a b -> Kleisli m a c
(.#) Kleisli m b c
pbc q a b
_ = coerce :: forall a b. Coercible a b => a -> b
coerce Kleisli m b c
pbc
{-# INLINE (.#) #-}
instance Functor w => Profunctor (Cokleisli w) where
dimap :: forall a b c d.
(a -> b) -> (c -> d) -> Cokleisli w b c -> Cokleisli w a d
dimap a -> b
f c -> d
g (Cokleisli w b -> c
h) = forall {k} (w :: k -> *) (a :: k) b. (w a -> b) -> Cokleisli w a b
Cokleisli (c -> d
g forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. w b -> c
h forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f)
{-# INLINE dimap #-}
lmap :: forall a b c. (a -> b) -> Cokleisli w b c -> Cokleisli w a c
lmap a -> b
k (Cokleisli w b -> c
f) = forall {k} (w :: k -> *) (a :: k) b. (w a -> b) -> Cokleisli w a b
Cokleisli (w b -> c
f forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
k)
{-# INLINE lmap #-}
rmap :: forall b c a. (b -> c) -> Cokleisli w a b -> Cokleisli w a c
rmap b -> c
k (Cokleisli w a -> b
f) = forall {k} (w :: k -> *) (a :: k) b. (w a -> b) -> Cokleisli w a b
Cokleisli (b -> c
k forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. w a -> b
f)
{-# INLINE rmap #-}
#. :: forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Cokleisli w a b -> Cokleisli w a c
(#.) q b c
_ = coerce :: forall a b. Coercible a b => a -> b
coerce (\b
x -> b
x :: b) :: forall a b. Coercible b a => a -> b
{-# INLINE (#.) #-}
instance Contravariant f => Profunctor (Clown f) where
lmap :: forall a b c. (a -> b) -> Clown f b c -> Clown f a c
lmap a -> b
f (Clown f b
fa) = forall {k} {k1} (f :: k -> *) (a :: k) (b :: k1).
f a -> Clown f a b
Clown (forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap a -> b
f f b
fa)
{-# INLINE lmap #-}
rmap :: forall b c a. (b -> c) -> Clown f a b -> Clown f a c
rmap b -> c
_ (Clown f a
fa) = forall {k} {k1} (f :: k -> *) (a :: k) (b :: k1).
f a -> Clown f a b
Clown f a
fa
{-# INLINE rmap #-}
dimap :: forall a b c d. (a -> b) -> (c -> d) -> Clown f b c -> Clown f a d
dimap a -> b
f c -> d
_ (Clown f b
fa) = forall {k} {k1} (f :: k -> *) (a :: k) (b :: k1).
f a -> Clown f a b
Clown (forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap a -> b
f f b
fa)
{-# INLINE dimap #-}
instance Functor f => Profunctor (Joker f) where
lmap :: forall a b c. (a -> b) -> Joker f b c -> Joker f a c
lmap a -> b
_ (Joker f c
fb) = forall {k} {k1} (g :: k -> *) (a :: k1) (b :: k).
g b -> Joker g a b
Joker f c
fb
{-# INLINE lmap #-}
rmap :: forall b c a. (b -> c) -> Joker f a b -> Joker f a c
rmap b -> c
g (Joker f b
fb) = forall {k} {k1} (g :: k -> *) (a :: k1) (b :: k).
g b -> Joker g a b
Joker (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> c
g f b
fb)
{-# INLINE rmap #-}
dimap :: forall a b c d. (a -> b) -> (c -> d) -> Joker f b c -> Joker f a d
dimap a -> b
_ c -> d
g (Joker f c
fb) = forall {k} {k1} (g :: k -> *) (a :: k1) (b :: k).
g b -> Joker g a b
Joker (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> d
g f c
fb)
{-# INLINE dimap #-}
instance (Profunctor p, Functor f, Functor g) => Profunctor (Biff p f g) where
lmap :: forall a b c. (a -> b) -> Biff p f g b c -> Biff p f g a c
lmap a -> b
f (Biff p (f b) (g c)
p) = forall {k} {k1} {k2} {k3} (p :: k -> k1 -> *) (f :: k2 -> k)
(g :: k3 -> k1) (a :: k2) (b :: k3).
p (f a) (g b) -> Biff p f g a b
Biff (forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) p (f b) (g c)
p)
rmap :: forall b c a. (b -> c) -> Biff p f g a b -> Biff p f g a c
rmap b -> c
g (Biff p (f a) (g b)
p) = forall {k} {k1} {k2} {k3} (p :: k -> k1 -> *) (f :: k2 -> k)
(g :: k3 -> k1) (a :: k2) (b :: k3).
p (f a) (g b) -> Biff p f g a b
Biff (forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> c
g) p (f a) (g b)
p)
dimap :: forall a b c d.
(a -> b) -> (c -> d) -> Biff p f g b c -> Biff p f g a d
dimap a -> b
f c -> d
g (Biff p (f b) (g c)
p) = forall {k} {k1} {k2} {k3} (p :: k -> k1 -> *) (f :: k2 -> k)
(g :: k3 -> k1) (a :: k2) (b :: k3).
p (f a) (g b) -> Biff p f g a b
Biff (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> d
g) p (f b) (g c)
p)
instance (Profunctor p, Profunctor q) => Profunctor (Product p q) where
lmap :: forall a b c. (a -> b) -> Product p q b c -> Product p q a c
lmap a -> b
f (Pair p b c
p q b c
q) = forall {k} {k1} (f :: k -> k1 -> *) (g :: k -> k1 -> *) (a :: k)
(b :: k1).
f a b -> g a b -> Product f g a b
Pair (forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap a -> b
f p b c
p) (forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap a -> b
f q b c
q)
{-# INLINE lmap #-}
rmap :: forall b c a. (b -> c) -> Product p q a b -> Product p q a c
rmap b -> c
g (Pair p a b
p q a b
q) = forall {k} {k1} (f :: k -> k1 -> *) (g :: k -> k1 -> *) (a :: k)
(b :: k1).
f a b -> g a b -> Product f g a b
Pair (forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap b -> c
g p a b
p) (forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap b -> c
g q a b
q)
{-# INLINE rmap #-}
dimap :: forall a b c d.
(a -> b) -> (c -> d) -> Product p q b c -> Product p q a d
dimap a -> b
f c -> d
g (Pair p b c
p q b c
q) = forall {k} {k1} (f :: k -> k1 -> *) (g :: k -> k1 -> *) (a :: k)
(b :: k1).
f a b -> g a b -> Product f g a b
Pair (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap a -> b
f c -> d
g p b c
p) (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap a -> b
f c -> d
g q b c
q)
{-# INLINE dimap #-}
#. :: forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Product p q a b -> Product p q a c
(#.) q b c
f (Pair p a b
p q a b
q) = forall {k} {k1} (f :: k -> k1 -> *) (g :: k -> k1 -> *) (a :: k)
(b :: k1).
f a b -> g a b -> Product f g a b
Pair (q b c
f forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. p a b
p) (q b c
f forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. q a b
q)
{-# INLINE (#.) #-}
.# :: forall a b c (q :: * -> * -> *).
Coercible b a =>
Product p q b c -> q a b -> Product p q a c
(.#) (Pair p b c
p q b c
q) q a b
f = forall {k} {k1} (f :: k -> k1 -> *) (g :: k -> k1 -> *) (a :: k)
(b :: k1).
f a b -> g a b -> Product f g a b
Pair (p b c
p forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# q a b
f) (q b c
q forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# q a b
f)
{-# INLINE (.#) #-}
instance (Profunctor p, Profunctor q) => Profunctor (Sum p q) where
lmap :: forall a b c. (a -> b) -> Sum p q b c -> Sum p q a c
lmap a -> b
f (L2 p b c
x) = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
p a b -> Sum p q a b
L2 (forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap a -> b
f p b c
x)
lmap a -> b
f (R2 q b c
y) = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
q a b -> Sum p q a b
R2 (forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap a -> b
f q b c
y)
{-# INLINE lmap #-}
rmap :: forall b c a. (b -> c) -> Sum p q a b -> Sum p q a c
rmap b -> c
g (L2 p a b
x) = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
p a b -> Sum p q a b
L2 (forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap b -> c
g p a b
x)
rmap b -> c
g (R2 q a b
y) = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
q a b -> Sum p q a b
R2 (forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap b -> c
g q a b
y)
{-# INLINE rmap #-}
dimap :: forall a b c d. (a -> b) -> (c -> d) -> Sum p q b c -> Sum p q a d
dimap a -> b
f c -> d
g (L2 p b c
x) = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
p a b -> Sum p q a b
L2 (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap a -> b
f c -> d
g p b c
x)
dimap a -> b
f c -> d
g (R2 q b c
y) = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
q a b -> Sum p q a b
R2 (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap a -> b
f c -> d
g q b c
y)
{-# INLINE dimap #-}
q b c
f #. :: forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Sum p q a b -> Sum p q a c
#. L2 p a b
x = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
p a b -> Sum p q a b
L2 (q b c
f forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. p a b
x)
q b c
f #. R2 q a b
y = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
q a b -> Sum p q a b
R2 (q b c
f forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. q a b
y)
{-# INLINE (#.) #-}
L2 p b c
x .# :: forall a b c (q :: * -> * -> *).
Coercible b a =>
Sum p q b c -> q a b -> Sum p q a c
.# q a b
f = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
p a b -> Sum p q a b
L2 (p b c
x forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# q a b
f)
R2 q b c
y .# q a b
f = forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
q a b -> Sum p q a b
R2 (q b c
y forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# q a b
f)
{-# INLINE (.#) #-}
instance (Functor f, Profunctor p) => Profunctor (Tannen f p) where
lmap :: forall a b c. (a -> b) -> Tannen f p b c -> Tannen f p a c
lmap a -> b
f (Tannen f (p b c)
h) = forall {k} {k1} {k2} (f :: k -> *) (p :: k1 -> k2 -> k) (a :: k1)
(b :: k2).
f (p a b) -> Tannen f p a b
Tannen (forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap a -> b
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (p b c)
h)
{-# INLINE lmap #-}
rmap :: forall b c a. (b -> c) -> Tannen f p a b -> Tannen f p a c
rmap b -> c
g (Tannen f (p a b)
h) = forall {k} {k1} {k2} (f :: k -> *) (p :: k1 -> k2 -> k) (a :: k1)
(b :: k2).
f (p a b) -> Tannen f p a b
Tannen (forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap b -> c
g forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (p a b)
h)
{-# INLINE rmap #-}
dimap :: forall a b c d.
(a -> b) -> (c -> d) -> Tannen f p b c -> Tannen f p a d
dimap a -> b
f c -> d
g (Tannen f (p b c)
h) = forall {k} {k1} {k2} (f :: k -> *) (p :: k1 -> k2 -> k) (a :: k1)
(b :: k2).
f (p a b) -> Tannen f p a b
Tannen (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap a -> b
f c -> d
g forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (p b c)
h)
{-# INLINE dimap #-}
#. :: forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Tannen f p a b -> Tannen f p a c
(#.) q b c
f (Tannen f (p a b)
h) = forall {k} {k1} {k2} (f :: k -> *) (p :: k1 -> k2 -> k) (a :: k1)
(b :: k2).
f (p a b) -> Tannen f p a b
Tannen ((q b c
f forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#.) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (p a b)
h)
{-# INLINE (#.) #-}
.# :: forall a b c (q :: * -> * -> *).
Coercible b a =>
Tannen f p b c -> q a b -> Tannen f p a c
(.#) (Tannen f (p b c)
h) q a b
f = forall {k} {k1} {k2} (f :: k -> *) (p :: k1 -> k2 -> k) (a :: k1)
(b :: k2).
f (p a b) -> Tannen f p a b
Tannen ((forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# q a b
f) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (p b c)
h)
{-# INLINE (.#) #-}