{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeOperators #-}
module Data.Functor.Bicompose where

import Control.Applicative (Alternative)
import Control.Monad (join)
import Data.Functor.Classes (Eq1, Ord1)
import Data.Functor.Compose
import Data.Kind (Type)
import FMonad
import FComonad

import Data.Functor.Precompose (type (:.:))
import Control.Comonad

-- | Both-side composition of Monad.
--
-- If both of @f@ and @g@ are @Monad@, @Bicompose f g@ is an instance of 'FMonad' in a similar way
-- 'Compose' and 'Data.Functor.Precompose.Precompose' are.
type Bicompose :: (k2 -> Type) -> (k0 -> k1) -> (k1 -> k2) -> k0 -> Type
newtype Bicompose f g h a = Bicompose {forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Bicompose f g h a -> f (h (g a))
getBicompose :: f (h (g a))}
  deriving stock (Int -> Bicompose f g h a -> ShowS
[Bicompose f g h a] -> ShowS
Bicompose f g h a -> String
(Int -> Bicompose f g h a -> ShowS)
-> (Bicompose f g h a -> String)
-> ([Bicompose f g h a] -> ShowS)
-> Show (Bicompose f g h a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Show (f (h (g a))) =>
Int -> Bicompose f g h a -> ShowS
forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Show (f (h (g a))) =>
[Bicompose f g h a] -> ShowS
forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Show (f (h (g a))) =>
Bicompose f g h a -> String
$cshowsPrec :: forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Show (f (h (g a))) =>
Int -> Bicompose f g h a -> ShowS
showsPrec :: Int -> Bicompose f g h a -> ShowS
$cshow :: forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Show (f (h (g a))) =>
Bicompose f g h a -> String
show :: Bicompose f g h a -> String
$cshowList :: forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Show (f (h (g a))) =>
[Bicompose f g h a] -> ShowS
showList :: [Bicompose f g h a] -> ShowS
Show, ReadPrec [Bicompose f g h a]
ReadPrec (Bicompose f g h a)
Int -> ReadS (Bicompose f g h a)
ReadS [Bicompose f g h a]
(Int -> ReadS (Bicompose f g h a))
-> ReadS [Bicompose f g h a]
-> ReadPrec (Bicompose f g h a)
-> ReadPrec [Bicompose f g h a]
-> Read (Bicompose f g h a)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Read (f (h (g a))) =>
ReadPrec [Bicompose f g h a]
forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Read (f (h (g a))) =>
ReadPrec (Bicompose f g h a)
forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Read (f (h (g a))) =>
Int -> ReadS (Bicompose f g h a)
forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Read (f (h (g a))) =>
ReadS [Bicompose f g h a]
$creadsPrec :: forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Read (f (h (g a))) =>
Int -> ReadS (Bicompose f g h a)
readsPrec :: Int -> ReadS (Bicompose f g h a)
$creadList :: forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Read (f (h (g a))) =>
ReadS [Bicompose f g h a]
readList :: ReadS [Bicompose f g h a]
$creadPrec :: forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Read (f (h (g a))) =>
ReadPrec (Bicompose f g h a)
readPrec :: ReadPrec (Bicompose f g h a)
$creadListPrec :: forall k2 (f :: k2 -> *) k1 k0 (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Read (f (h (g a))) =>
ReadPrec [Bicompose f g h a]
readListPrec :: ReadPrec [Bicompose f g h a]
Read, (forall a b. (a -> b) -> Bicompose f g h a -> Bicompose f g h b)
-> (forall a b. a -> Bicompose f g h b -> Bicompose f g h a)
-> Functor (Bicompose f g h)
forall a b. a -> Bicompose f g h b -> Bicompose f g h a
forall a b. (a -> b) -> Bicompose f g h a -> Bicompose f g h b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Functor f, Functor h, Functor g) =>
a -> Bicompose f g h b -> Bicompose f g h a
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Functor f, Functor h, Functor g) =>
(a -> b) -> Bicompose f g h a -> Bicompose f g h b
$cfmap :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Functor f, Functor h, Functor g) =>
(a -> b) -> Bicompose f g h a -> Bicompose f g h b
fmap :: forall a b. (a -> b) -> Bicompose f g h a -> Bicompose f g h b
$c<$ :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Functor f, Functor h, Functor g) =>
a -> Bicompose f g h b -> Bicompose f g h a
<$ :: forall a b. a -> Bicompose f g h b -> Bicompose f g h a
Functor, (forall m. Monoid m => Bicompose f g h m -> m)
-> (forall m a. Monoid m => (a -> m) -> Bicompose f g h a -> m)
-> (forall m a. Monoid m => (a -> m) -> Bicompose f g h a -> m)
-> (forall a b. (a -> b -> b) -> b -> Bicompose f g h a -> b)
-> (forall a b. (a -> b -> b) -> b -> Bicompose f g h a -> b)
-> (forall b a. (b -> a -> b) -> b -> Bicompose f g h a -> b)
-> (forall b a. (b -> a -> b) -> b -> Bicompose f g h a -> b)
-> (forall a. (a -> a -> a) -> Bicompose f g h a -> a)
-> (forall a. (a -> a -> a) -> Bicompose f g h a -> a)
-> (forall a. Bicompose f g h a -> [a])
-> (forall a. Bicompose f g h a -> Bool)
-> (forall a. Bicompose f g h a -> Int)
-> (forall a. Eq a => a -> Bicompose f g h a -> Bool)
-> (forall a. Ord a => Bicompose f g h a -> a)
-> (forall a. Ord a => Bicompose f g h a -> a)
-> (forall a. Num a => Bicompose f g h a -> a)
-> (forall a. Num a => Bicompose f g h a -> a)
-> Foldable (Bicompose f g h)
forall a. Eq a => a -> Bicompose f g h a -> Bool
forall a. Num a => Bicompose f g h a -> a
forall a. Ord a => Bicompose f g h a -> a
forall m. Monoid m => Bicompose f g h m -> m
forall a. Bicompose f g h a -> Bool
forall a. Bicompose f g h a -> Int
forall a. Bicompose f g h a -> [a]
forall a. (a -> a -> a) -> Bicompose f g h a -> a
forall m a. Monoid m => (a -> m) -> Bicompose f g h a -> m
forall b a. (b -> a -> b) -> b -> Bicompose f g h a -> b
forall a b. (a -> b -> b) -> b -> Bicompose f g h a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g, Eq a) =>
a -> Bicompose f g h a -> Bool
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g, Num a) =>
Bicompose f g h a -> a
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g, Ord a) =>
Bicompose f g h a -> a
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) m.
(Foldable f, Foldable h, Foldable g, Monoid m) =>
Bicompose f g h m -> m
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g) =>
Bicompose f g h a -> Bool
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g) =>
Bicompose f g h a -> Int
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g) =>
Bicompose f g h a -> [a]
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g) =>
(a -> a -> a) -> Bicompose f g h a -> a
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) m a.
(Foldable f, Foldable h, Foldable g, Monoid m) =>
(a -> m) -> Bicompose f g h a -> m
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) b a.
(Foldable f, Foldable h, Foldable g) =>
(b -> a -> b) -> b -> Bicompose f g h a -> b
forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Foldable f, Foldable h, Foldable g) =>
(a -> b -> b) -> b -> Bicompose f g h a -> b
$cfold :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) m.
(Foldable f, Foldable h, Foldable g, Monoid m) =>
Bicompose f g h m -> m
fold :: forall m. Monoid m => Bicompose f g h m -> m
$cfoldMap :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) m a.
(Foldable f, Foldable h, Foldable g, Monoid m) =>
(a -> m) -> Bicompose f g h a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Bicompose f g h a -> m
$cfoldMap' :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) m a.
(Foldable f, Foldable h, Foldable g, Monoid m) =>
(a -> m) -> Bicompose f g h a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Bicompose f g h a -> m
$cfoldr :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Foldable f, Foldable h, Foldable g) =>
(a -> b -> b) -> b -> Bicompose f g h a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Bicompose f g h a -> b
$cfoldr' :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Foldable f, Foldable h, Foldable g) =>
(a -> b -> b) -> b -> Bicompose f g h a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Bicompose f g h a -> b
$cfoldl :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) b a.
(Foldable f, Foldable h, Foldable g) =>
(b -> a -> b) -> b -> Bicompose f g h a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Bicompose f g h a -> b
$cfoldl' :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) b a.
(Foldable f, Foldable h, Foldable g) =>
(b -> a -> b) -> b -> Bicompose f g h a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Bicompose f g h a -> b
$cfoldr1 :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g) =>
(a -> a -> a) -> Bicompose f g h a -> a
foldr1 :: forall a. (a -> a -> a) -> Bicompose f g h a -> a
$cfoldl1 :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g) =>
(a -> a -> a) -> Bicompose f g h a -> a
foldl1 :: forall a. (a -> a -> a) -> Bicompose f g h a -> a
$ctoList :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g) =>
Bicompose f g h a -> [a]
toList :: forall a. Bicompose f g h a -> [a]
$cnull :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g) =>
Bicompose f g h a -> Bool
null :: forall a. Bicompose f g h a -> Bool
$clength :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g) =>
Bicompose f g h a -> Int
length :: forall a. Bicompose f g h a -> Int
$celem :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g, Eq a) =>
a -> Bicompose f g h a -> Bool
elem :: forall a. Eq a => a -> Bicompose f g h a -> Bool
$cmaximum :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g, Ord a) =>
Bicompose f g h a -> a
maximum :: forall a. Ord a => Bicompose f g h a -> a
$cminimum :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g, Ord a) =>
Bicompose f g h a -> a
minimum :: forall a. Ord a => Bicompose f g h a -> a
$csum :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g, Num a) =>
Bicompose f g h a -> a
sum :: forall a. Num a => Bicompose f g h a -> a
$cproduct :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a.
(Foldable f, Foldable h, Foldable g, Num a) =>
Bicompose f g h a -> a
product :: forall a. Num a => Bicompose f g h a -> a
Foldable)

deriving stock instance
  (Traversable f, Traversable g, Traversable h) => Traversable (Bicompose f g h)

deriving via
  ((f :.: h :.: g) a)
  instance
    (Eq1 f, Eq1 g, Eq1 h, Eq a) => Eq (Bicompose f g h a)

deriving via
  ((f :.: h :.: g) a)
  instance
    (Ord1 f, Ord1 g, Ord1 h, Ord a) => Ord (Bicompose f g h a)

deriving via
  (f :.: h :.: g)
  instance
    (Applicative f, Applicative g, Applicative h) => Applicative (Bicompose f g h)

deriving via
  (f :.: h :.: g)
  instance
    (Alternative f, Applicative g, Applicative h) => Alternative (Bicompose f g h)

instance (Functor f, Functor g) => FFunctor (Bicompose f g) where
  ffmap :: forall (g :: * -> *) (h :: * -> *) x.
(Functor g, Functor h) =>
(g ~> h) -> Bicompose f g g x -> Bicompose f g h x
ffmap g ~> h
gh = f (h (g x)) -> Bicompose f g h x
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
f (h (g a)) -> Bicompose f g h a
Bicompose (f (h (g x)) -> Bicompose f g h x)
-> (Bicompose f g g x -> f (h (g x)))
-> Bicompose f g g x
-> Bicompose f g h x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (g (g x) -> h (g x)) -> f (g (g x)) -> f (h (g x))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap g (g x) -> h (g x)
g ~> h
gh (f (g (g x)) -> f (h (g x)))
-> (Bicompose f g g x -> f (g (g x)))
-> Bicompose f g g x
-> f (h (g x))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bicompose f g g x -> f (g (g x))
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Bicompose f g h a -> f (h (g a))
getBicompose

instance (Monad f, Monad g) => FMonad (Bicompose f g) where
  fpure :: forall (g :: * -> *). Functor g => g ~> Bicompose f g g
fpure = f (g (g x)) -> Bicompose f g g x
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
f (h (g a)) -> Bicompose f g h a
Bicompose (f (g (g x)) -> Bicompose f g g x)
-> (g x -> f (g (g x))) -> g x -> Bicompose f g g x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (g x) -> f (g (g x))
forall a. a -> f a
forall (m :: * -> *) a. Monad m => a -> m a
return (g (g x) -> f (g (g x))) -> (g x -> g (g x)) -> g x -> f (g (g x))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (x -> g x) -> g x -> g (g x)
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap x -> g x
forall a. a -> g a
forall (m :: * -> *) a. Monad m => a -> m a
return
  fbind :: forall (g :: * -> *) (h :: * -> *) a.
(Functor g, Functor h) =>
(g ~> Bicompose f g h) -> Bicompose f g g a -> Bicompose f g h a
fbind g ~> Bicompose f g h
k = f (h (g a)) -> Bicompose f g h a
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
f (h (g a)) -> Bicompose f g h a
Bicompose (f (h (g a)) -> Bicompose f g h a)
-> (Bicompose f g g a -> f (h (g a)))
-> Bicompose f g g a
-> Bicompose f g h a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (h (g (g a)) -> h (g a)) -> f (h (g (g a))) -> f (h (g a))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((g (g a) -> g a) -> h (g (g a)) -> h (g a)
forall a b. (a -> b) -> h a -> h b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap g (g a) -> g a
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join) (f (h (g (g a))) -> f (h (g a)))
-> (Bicompose f g g a -> f (h (g (g a))))
-> Bicompose f g g a
-> f (h (g a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bicompose f g h (g a) -> f (h (g (g a)))
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Bicompose f g h a -> f (h (g a))
getBicompose (Bicompose f g h (g a) -> f (h (g (g a))))
-> (g (g a) -> Bicompose f g h (g a)) -> g (g a) -> f (h (g (g a)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (g a) -> Bicompose f g h (g a)
g ~> Bicompose f g h
k (g (g a) -> f (h (g (g a)))) -> f (g (g a)) -> f (h (g (g a)))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (f (g (g a)) -> f (h (g (g a))))
-> (Bicompose f g g a -> f (g (g a)))
-> Bicompose f g g a
-> f (h (g (g a)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bicompose f g g a -> f (g (g a))
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Bicompose f g h a -> f (h (g a))
getBicompose

instance (Comonad f, Comonad g) => FComonad (Bicompose f g) where
  fextract :: forall (g :: * -> *). Functor g => Bicompose f g g ~> g
fextract = (g x -> x) -> g (g x) -> g x
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap g x -> x
forall a. g a -> a
forall (w :: * -> *) a. Comonad w => w a -> a
extract (g (g x) -> g x)
-> (Bicompose f g g x -> g (g x)) -> Bicompose f g g x -> g x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (g (g x)) -> g (g x)
forall a. f a -> a
forall (w :: * -> *) a. Comonad w => w a -> a
extract (f (g (g x)) -> g (g x))
-> (Bicompose f g g x -> f (g (g x)))
-> Bicompose f g g x
-> g (g x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bicompose f g g x -> f (g (g x))
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Bicompose f g h a -> f (h (g a))
getBicompose
  fextend :: forall (g :: * -> *) (h :: * -> *).
(Functor g, Functor h) =>
(Bicompose f g g ~> h) -> Bicompose f g g ~> Bicompose f g h
fextend Bicompose f g g ~> h
tr = f (h (g x)) -> Bicompose f g h x
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
f (h (g a)) -> Bicompose f g h a
Bicompose (f (h (g x)) -> Bicompose f g h x)
-> (Bicompose f g g x -> f (h (g x)))
-> Bicompose f g g x
-> Bicompose f g h x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (f (g (g (g x))) -> h (g x)) -> f (g (g (g x))) -> f (h (g x))
forall a b. (f a -> b) -> f a -> f b
forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
extend (Bicompose f g g (g x) -> h (g x)
Bicompose f g g ~> h
tr (Bicompose f g g (g x) -> h (g x))
-> (f (g (g (g x))) -> Bicompose f g g (g x))
-> f (g (g (g x)))
-> h (g x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (g (g (g x))) -> Bicompose f g g (g x)
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
f (h (g a)) -> Bicompose f g h a
Bicompose) (f (g (g (g x))) -> f (h (g x)))
-> (Bicompose f g g x -> f (g (g (g x))))
-> Bicompose f g g x
-> f (h (g x))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (g (g x) -> g (g (g x))) -> f (g (g x)) -> f (g (g (g x)))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((g x -> g (g x)) -> g (g x) -> g (g (g x))
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap g x -> g (g x)
forall a. g a -> g (g a)
forall (w :: * -> *) a. Comonad w => w a -> w (w a)
duplicate) (f (g (g x)) -> f (g (g (g x))))
-> (Bicompose f g g x -> f (g (g x)))
-> Bicompose f g g x
-> f (g (g (g x)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bicompose f g g x -> f (g (g x))
forall k2 k0 k1 (f :: k2 -> *) (g :: k0 -> k1) (h :: k1 -> k2)
       (a :: k0).
Bicompose f g h a -> f (h (g a))
getBicompose