{-# LANGUAGE CPP #-}
#if !(MIN_VERSION_base(4,16,0)) || !(MIN_VERSION_transformers(0,6,0))
{-# OPTIONS_GHC -fno-warn-deprecations #-}
#endif
#define GHC_GENERICS_OK __GLASGOW_HASKELL__ >= 702
#if GHC_GENERICS_OK
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
#endif
#if __GLASGOW_HASKELL__ >= 706
{-# LANGUAGE PolyKinds #-}
#endif
module Data.Functor.Invariant
(
Invariant(..)
, invmapFunctor
#if GHC_GENERICS_OK
, genericInvmap
#endif
, WrappedFunctor(..)
, invmapContravariant
, invmapProfunctor
, invmapArrow
, WrappedContravariant(..)
, InvariantProfunctor(..)
, InvariantArrow(..)
, Invariant2(..)
, invmap2Bifunctor
, WrappedBifunctor(..)
, invmap2Profunctor
, WrappedProfunctor(..)
) where
import Control.Applicative as App
import qualified Control.Arrow as Arr
import Control.Arrow hiding (first, second)
import qualified Control.Category as Cat
import Control.Exception (Handler(..))
import Control.Monad (MonadPlus(..), liftM)
import qualified Control.Monad.ST as Strict (ST)
import qualified Control.Monad.ST.Lazy as Lazy (ST)
#if MIN_VERSION_base(4,4,0)
import Data.Complex (Complex(..))
#endif
import qualified Data.Foldable as F (Foldable(..))
import qualified Data.Functor.Compose as Functor (Compose(..))
import Data.Functor.Identity (Identity)
import Data.Functor.Product as Functor (Product(..))
import Data.Functor.Sum as Functor (Sum(..))
#if __GLASGOW_HASKELL__ < 711
import Data.Ix (Ix)
#endif
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.Monoid as Monoid (First(..), Last(..), Product(..), Sum(..))
#if MIN_VERSION_base(4,8,0)
import Data.Monoid (Alt(..))
#endif
import Data.Monoid (Dual(..), Endo(..))
import Data.Proxy (Proxy(..))
import qualified Data.Semigroup as Semigroup (First(..), Last(..))
#if !(MIN_VERSION_base(4,16,0))
import qualified Data.Semigroup as Semigroup (Option(..))
#endif
import Data.Semigroup (Min(..), Max(..), Arg(..))
import qualified Data.Traversable as T (Traversable(..))
#if GHC_GENERICS_OK
import GHC.Generics
#endif
import System.Console.GetOpt as GetOpt
import Text.ParserCombinators.ReadP (ReadP)
import Text.ParserCombinators.ReadPrec (ReadPrec)
import Data.Array (Array)
import Data.Bifunctor
import Data.Bifunctor.Biff
import Data.Bifunctor.Clown
import Data.Bifunctor.Fix
import Data.Bifunctor.Flip
import Data.Bifunctor.Join
import Data.Bifunctor.Joker
import qualified Data.Bifunctor.Product as Bifunctor
import qualified Data.Bifunctor.Sum as Bifunctor
import Data.Bifunctor.Tannen
import Data.Bifunctor.Wrapped
import Control.Comonad (Cokleisli(..))
import Data.IntMap (IntMap)
import Data.Map (Map)
import Data.Sequence (Seq, ViewL, ViewR)
import Data.Tree (Tree)
import Data.Functor.Contravariant
import Data.Functor.Contravariant.Compose as Contravariant
import Data.Functor.Contravariant.Divisible
import Data.Profunctor as Pro
import Data.Profunctor.Cayley
import Data.Profunctor.Choice
import Data.Profunctor.Closed
import Data.Profunctor.Composition
import Data.Profunctor.Mapping
import Data.Profunctor.Monad
import Data.Profunctor.Rep
import Data.Profunctor.Ran
import Data.Profunctor.Strong
import Data.Profunctor.Traversing
import Data.Profunctor.Unsafe
import Data.Profunctor.Yoneda
import Data.StateVar (StateVar(..), SettableStateVar(..))
import Control.Concurrent.STM (STM)
import Data.Tagged (Tagged(..))
import Control.Applicative.Backwards (Backwards(..))
import Control.Applicative.Lift (Lift(..))
import Control.Monad.Trans.Cont (ContT)
import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
import Control.Monad.Trans.Identity (IdentityT, mapIdentityT)
import Control.Monad.Trans.Maybe (MaybeT, mapMaybeT)
import qualified Control.Monad.Trans.RWS.Lazy as Lazy (RWST(..))
import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST(..))
import Control.Monad.Trans.Reader (ReaderT, mapReaderT)
import qualified Control.Monad.Trans.State.Lazy as Lazy (StateT(..))
import qualified Control.Monad.Trans.State.Strict as Strict (StateT(..))
import qualified Control.Monad.Trans.Writer.Lazy as Lazy (WriterT, mapWriterT)
import qualified Control.Monad.Trans.Writer.Strict as Strict (WriterT, mapWriterT)
#if !(MIN_VERSION_transformers(0,6,0))
import Control.Monad.Trans.Error (ErrorT(..))
import Control.Monad.Trans.List (ListT, mapListT)
#endif
import Data.Functor.Constant (Constant(..))
import Data.Functor.Reverse (Reverse(..))
import Data.HashMap.Lazy (HashMap)
class Invariant f where
invmap :: (a -> b) -> (b -> a) -> f a -> f b
#if GHC_GENERICS_OK
default invmap :: (Generic1 f, Invariant (Rep1 f)) => (a -> b) -> (b -> a) -> f a -> f b
invmap = (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
(Generic1 f, Invariant (Rep1 f)) =>
(a -> b) -> (b -> a) -> f a -> f b
genericInvmap
#endif
invmapFunctor :: Functor f => (a -> b) -> (b -> a) -> f a -> f b
invmapFunctor :: forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor = ((b -> a) -> (a -> b) -> f a -> f b)
-> (a -> b) -> (b -> a) -> f a -> f b
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((b -> a) -> (a -> b) -> f a -> f b)
-> (a -> b) -> (b -> a) -> f a -> f b)
-> ((b -> a) -> (a -> b) -> f a -> f b)
-> (a -> b)
-> (b -> a)
-> f a
-> f b
forall a b. (a -> b) -> a -> b
$ ((a -> b) -> f a -> f b) -> (b -> a) -> (a -> b) -> f a -> f b
forall a b. a -> b -> a
const (a -> b) -> f a -> f b
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
invmapContravariant :: Contravariant f => (a -> b) -> (b -> a) -> f a -> f b
invmapContravariant :: forall (f :: * -> *) a b.
Contravariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapContravariant = ((b -> a) -> f a -> f b) -> (a -> b) -> (b -> a) -> f a -> f b
forall a b. a -> b -> a
const (b -> a) -> f a -> f b
forall a' a. (a' -> a) -> f a -> f a'
forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap
invmapProfunctor :: Profunctor p => (a -> b) -> (b -> a) -> p a a -> p b b
invmapProfunctor :: forall (p :: * -> * -> *) a b.
Profunctor p =>
(a -> b) -> (b -> a) -> p a a -> p b b
invmapProfunctor = ((b -> a) -> (a -> b) -> p a a -> p b b)
-> (a -> b) -> (b -> a) -> p a a -> p b b
forall a b c. (a -> b -> c) -> b -> a -> c
flip (b -> a) -> (a -> b) -> p a a -> p b b
forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap
invmapArrow :: Arrow arr => (a -> b) -> (b -> a) -> arr a a -> arr b b
invmapArrow :: forall (arr :: * -> * -> *) a b.
Arrow arr =>
(a -> b) -> (b -> a) -> arr a a -> arr b b
invmapArrow a -> b
fn1 b -> a
fn2 arr a a
arrow = (a -> b) -> arr a b
forall b c. (b -> c) -> arr b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr a -> b
fn1 arr a b -> arr b a -> arr b b
forall b c a. arr b c -> arr a b -> arr a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
Cat.. arr a a
arrow arr a a -> arr b a -> arr b a
forall b c a. arr b c -> arr a b -> arr a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
Cat.. (b -> a) -> arr b a
forall b c. (b -> c) -> arr b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr b -> a
fn2
instance Invariant Maybe where invmap :: forall a b. (a -> b) -> (b -> a) -> Maybe a -> Maybe b
invmap = (a -> b) -> (b -> a) -> Maybe a -> Maybe b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant [] where invmap :: forall a b. (a -> b) -> (b -> a) -> [a] -> [b]
invmap = (a -> b) -> (b -> a) -> [a] -> [b]
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant IO where invmap :: forall a b. (a -> b) -> (b -> a) -> IO a -> IO b
invmap = (a -> b) -> (b -> a) -> IO a -> IO b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant (Strict.ST s) where invmap :: forall a b. (a -> b) -> (b -> a) -> ST s a -> ST s b
invmap = (a -> b) -> (b -> a) -> ST s a -> ST s b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant (Lazy.ST s) where invmap :: forall a b. (a -> b) -> (b -> a) -> ST s a -> ST s b
invmap = (a -> b) -> (b -> a) -> ST s a -> ST s b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant ReadP where invmap :: forall a b. (a -> b) -> (b -> a) -> ReadP a -> ReadP b
invmap = (a -> b) -> (b -> a) -> ReadP a -> ReadP b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant ReadPrec where invmap :: forall a b. (a -> b) -> (b -> a) -> ReadPrec a -> ReadPrec b
invmap = (a -> b) -> (b -> a) -> ReadPrec a -> ReadPrec b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant ((->) a) where invmap :: forall a b. (a -> b) -> (b -> a) -> (a -> a) -> a -> b
invmap = (a -> b) -> (b -> a) -> (a -> a) -> a -> b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant (Either a) where invmap :: forall a b. (a -> b) -> (b -> a) -> Either a a -> Either a b
invmap = (a -> b) -> (b -> a) -> Either a a -> Either a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant ((,) a) where invmap :: forall a b. (a -> b) -> (b -> a) -> (a, a) -> (a, b)
invmap = (a -> b) -> (b -> a) -> (a, a) -> (a, b)
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant ((,,) a b) where invmap :: forall a b. (a -> b) -> (b -> a) -> (a, b, a) -> (a, b, b)
invmap a -> b
f b -> a
_ ~(a
a, b
b, a
x) = (a
a, b
b, a -> b
f a
x)
instance Invariant ((,,,) a b c) where
invmap :: forall a b. (a -> b) -> (b -> a) -> (a, b, c, a) -> (a, b, c, b)
invmap a -> b
f b -> a
_ ~(a
a, b
b, c
c, a
x) = (a
a, b
b, c
c, a -> b
f a
x)
instance Invariant ((,,,,) a b c d) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> (a, b, c, d, a) -> (a, b, c, d, b)
invmap a -> b
f b -> a
_ ~(a
a, b
b, c
c, d
d, a
x) = (a
a, b
b, c
c, d
d, a -> b
f a
x)
instance Invariant (Const a) where invmap :: forall a b. (a -> b) -> (b -> a) -> Const a a -> Const a b
invmap = (a -> b) -> (b -> a) -> Const a a -> Const a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant ZipList where invmap :: forall a b. (a -> b) -> (b -> a) -> ZipList a -> ZipList b
invmap = (a -> b) -> (b -> a) -> ZipList a -> ZipList b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Monad m => Invariant (WrappedMonad m) where invmap :: forall a b.
(a -> b) -> (b -> a) -> WrappedMonad m a -> WrappedMonad m b
invmap = (a -> b) -> (b -> a) -> WrappedMonad m a -> WrappedMonad m b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Arrow arr => Invariant (App.WrappedArrow arr a) where
invmap :: forall a b.
(a -> b)
-> (b -> a) -> WrappedArrow arr a a -> WrappedArrow arr a b
invmap a -> b
f b -> a
_ (App.WrapArrow arr a a
x) = arr a b -> WrappedArrow arr a b
forall (a :: * -> * -> *) b c. a b c -> WrappedArrow a b c
App.WrapArrow (arr a b -> WrappedArrow arr a b)
-> arr a b -> WrappedArrow arr a b
forall a b. (a -> b) -> a -> b
$ (((a -> b) -> arr a b
forall b c. (b -> c) -> arr b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr a -> b
f) arr a b -> arr a a -> arr a b
forall b c a. arr b c -> arr a b -> arr a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
Cat.. arr a a
x)
instance
#if MIN_VERSION_base(4,4,0)
Arrow a
#else
ArrowApply a
#endif
=> Invariant (ArrowMonad a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> ArrowMonad a a -> ArrowMonad a b
invmap a -> b
f b -> a
_ (ArrowMonad a () a
m) = a () b -> ArrowMonad a b
forall (a :: * -> * -> *) b. a () b -> ArrowMonad a b
ArrowMonad (a () a
m a () a -> a a b -> a () b
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (a -> b) -> a a b
forall b c. (b -> c) -> a b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr a -> b
f)
instance Invariant m => Invariant (Kleisli m a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Kleisli m a a -> Kleisli m a b
invmap a -> b
f b -> a
g (Kleisli a -> m a
m) = (a -> m b) -> Kleisli m a b
forall (m :: * -> *) a b. (a -> m b) -> Kleisli m a b
Kleisli ((a -> b) -> (b -> a) -> m a -> m b
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g (m a -> m b) -> (a -> m a) -> a -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m a
m)
instance Invariant Handler where
invmap :: forall a b. (a -> b) -> (b -> a) -> Handler a -> Handler b
invmap a -> b
f b -> a
_ (Handler e -> IO a
h) = (e -> IO b) -> Handler b
forall a e. Exception e => (e -> IO a) -> Handler a
Handler ((a -> b) -> IO a -> IO b
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (IO a -> IO b) -> (e -> IO a) -> e -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> IO a
h)
#if MIN_VERSION_base(4,4,0)
instance Invariant Complex where
invmap :: forall a b. (a -> b) -> (b -> a) -> Complex a -> Complex b
invmap a -> b
f b -> a
_ (a
r :+ a
i) = a -> b
f a
r b -> b -> Complex b
forall a. a -> a -> Complex a
:+ a -> b
f a
i
#endif
instance (Invariant f, Invariant g) => Invariant (Functor.Compose f g) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Compose f g a -> Compose f g b
invmap a -> b
f b -> a
g (Functor.Compose f (g a)
x) =
f (g b) -> Compose f g b
forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Functor.Compose ((g a -> g b) -> (g b -> g a) -> f (g a) -> f (g b)
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (b -> a) -> g a -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) ((b -> a) -> (a -> b) -> g b -> g a
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> a
g a -> b
f) f (g a)
x)
instance Invariant Identity where
invmap :: forall a b. (a -> b) -> (b -> a) -> Identity a -> Identity b
invmap = (a -> b) -> (b -> a) -> Identity a -> Identity b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance (Invariant f, Invariant g) => Invariant (Functor.Product f g) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Product f g a -> Product f g b
invmap a -> b
f b -> a
g (Functor.Pair f a
x g a
y) = f b -> g b -> Product f g b
forall {k} (f :: k -> *) (g :: k -> *) (a :: k).
f a -> g a -> Product f g a
Functor.Pair ((a -> b) -> (b -> a) -> f a -> f b
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g f a
x) ((a -> b) -> (b -> a) -> g a -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g g a
y)
instance (Invariant f, Invariant g) => Invariant (Functor.Sum f g) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Sum f g a -> Sum f g b
invmap a -> b
f b -> a
g (InL f a
x) = f b -> Sum f g b
forall {k} (f :: k -> *) (g :: k -> *) (a :: k). f a -> Sum f g a
InL ((a -> b) -> (b -> a) -> f a -> f b
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g f a
x)
invmap a -> b
f b -> a
g (InR g a
y) = g b -> Sum f g b
forall {k} (f :: k -> *) (g :: k -> *) (a :: k). g a -> Sum f g a
InR ((a -> b) -> (b -> a) -> g a -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g g a
y)
instance Invariant NonEmpty where
invmap :: forall a b. (a -> b) -> (b -> a) -> NonEmpty a -> NonEmpty b
invmap = (a -> b) -> (b -> a) -> NonEmpty a -> NonEmpty b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant Dual where
invmap :: forall a b. (a -> b) -> (b -> a) -> Dual a -> Dual b
invmap a -> b
f b -> a
_ (Dual a
x) = b -> Dual b
forall a. a -> Dual a
Dual (a -> b
f a
x)
instance Invariant Endo where
invmap :: forall a b. (a -> b) -> (b -> a) -> Endo a -> Endo b
invmap a -> b
f b -> a
g (Endo a -> a
x) = (b -> b) -> Endo b
forall a. (a -> a) -> Endo a
Endo (a -> b
f (a -> b) -> (b -> a) -> b -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
x (a -> a) -> (b -> a) -> b -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
g)
instance Invariant Monoid.First where
invmap :: forall a b. (a -> b) -> (b -> a) -> First a -> First b
invmap a -> b
f b -> a
g (Monoid.First Maybe a
x) = Maybe b -> First b
forall a. Maybe a -> First a
Monoid.First ((a -> b) -> (b -> a) -> Maybe a -> Maybe b
forall a b. (a -> b) -> (b -> a) -> Maybe a -> Maybe b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g Maybe a
x)
instance Invariant Monoid.Last where
invmap :: forall a b. (a -> b) -> (b -> a) -> Last a -> Last b
invmap a -> b
f b -> a
g (Monoid.Last Maybe a
x) = Maybe b -> Last b
forall a. Maybe a -> Last a
Monoid.Last ((a -> b) -> (b -> a) -> Maybe a -> Maybe b
forall a b. (a -> b) -> (b -> a) -> Maybe a -> Maybe b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g Maybe a
x)
instance Invariant Monoid.Product where
invmap :: forall a b. (a -> b) -> (b -> a) -> Product a -> Product b
invmap a -> b
f b -> a
_ (Monoid.Product a
x) = b -> Product b
forall a. a -> Product a
Monoid.Product (a -> b
f a
x)
instance Invariant Monoid.Sum where
invmap :: forall a b. (a -> b) -> (b -> a) -> Sum a -> Sum b
invmap a -> b
f b -> a
_ (Monoid.Sum a
x) = b -> Sum b
forall a. a -> Sum a
Monoid.Sum (a -> b
f a
x)
#if MIN_VERSION_base(4,8,0)
instance Invariant f => Invariant (Alt f) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Alt f a -> Alt f b
invmap a -> b
f b -> a
g (Alt f a
x) = f b -> Alt f b
forall {k} (f :: k -> *) (a :: k). f a -> Alt f a
Alt ((a -> b) -> (b -> a) -> f a -> f b
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g f a
x)
#endif
instance Invariant Proxy where
invmap :: forall a b. (a -> b) -> (b -> a) -> Proxy a -> Proxy b
invmap = (a -> b) -> (b -> a) -> Proxy a -> Proxy b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant Min where
invmap :: forall a b. (a -> b) -> (b -> a) -> Min a -> Min b
invmap = (a -> b) -> (b -> a) -> Min a -> Min b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant Max where
invmap :: forall a b. (a -> b) -> (b -> a) -> Max a -> Max b
invmap = (a -> b) -> (b -> a) -> Max a -> Max b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant Semigroup.First where
invmap :: forall a b. (a -> b) -> (b -> a) -> First a -> First b
invmap = (a -> b) -> (b -> a) -> First a -> First b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant Semigroup.Last where
invmap :: forall a b. (a -> b) -> (b -> a) -> Last a -> Last b
invmap = (a -> b) -> (b -> a) -> Last a -> Last b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant (Arg a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Arg a a -> Arg a b
invmap = (a -> b) -> (b -> a) -> Arg a a -> Arg a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
#if !(MIN_VERSION_base(4,16,0))
instance Invariant Semigroup.Option where
invmap = invmapFunctor
#endif
instance Invariant ArgDescr where
invmap :: forall a b. (a -> b) -> (b -> a) -> ArgDescr a -> ArgDescr b
invmap a -> b
f b -> a
_ (NoArg a
a) = b -> ArgDescr b
forall a. a -> ArgDescr a
NoArg (a -> b
f a
a)
invmap a -> b
f b -> a
_ (ReqArg String -> a
g String
s) = (String -> b) -> String -> ArgDescr b
forall a. (String -> a) -> String -> ArgDescr a
ReqArg (a -> b
f (a -> b) -> (String -> a) -> String -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> a
g) String
s
invmap a -> b
f b -> a
_ (OptArg Maybe String -> a
g String
s) = (Maybe String -> b) -> String -> ArgDescr b
forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg (a -> b
f (a -> b) -> (Maybe String -> a) -> Maybe String -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe String -> a
g) String
s
instance Invariant ArgOrder where
invmap :: forall a b. (a -> b) -> (b -> a) -> ArgOrder a -> ArgOrder b
invmap a -> b
_ b -> a
_ ArgOrder a
RequireOrder = ArgOrder b
forall a. ArgOrder a
RequireOrder
invmap a -> b
_ b -> a
_ ArgOrder a
Permute = ArgOrder b
forall a. ArgOrder a
Permute
invmap a -> b
f b -> a
_ (ReturnInOrder String -> a
g) = (String -> b) -> ArgOrder b
forall a. (String -> a) -> ArgOrder a
ReturnInOrder (a -> b
f (a -> b) -> (String -> a) -> String -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> a
g)
instance Invariant OptDescr where
invmap :: forall a b. (a -> b) -> (b -> a) -> OptDescr a -> OptDescr b
invmap a -> b
f b -> a
g (GetOpt.Option String
a [String]
b ArgDescr a
argDescr String
c) = String -> [String] -> ArgDescr b -> String -> OptDescr b
forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
GetOpt.Option String
a [String]
b ((a -> b) -> (b -> a) -> ArgDescr a -> ArgDescr b
forall a b. (a -> b) -> (b -> a) -> ArgDescr a -> ArgDescr b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g ArgDescr a
argDescr) String
c
instance
#if __GLASGOW_HASKELL__ < 711
Ix i =>
#endif
Invariant (Array i) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Array i a -> Array i b
invmap = (a -> b) -> (b -> a) -> Array i a -> Array i b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance (Invariant2 p, Invariant g) => Invariant (Biff p f g a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> Biff p f g a a -> Biff p f g a b
invmap a -> b
f b -> a
g = p (f a) (g b) -> Biff p f g a b
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 (p (f a) (g b) -> Biff p f g a b)
-> (Biff p f g a a -> p (f a) (g b))
-> Biff p f g a a
-> Biff p f g a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (f a -> f a)
-> (f a -> f a)
-> (g a -> g b)
-> (g b -> g a)
-> p (f a) (g a)
-> p (f a) (g b)
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 f a -> f a
forall a. a -> a
id f a -> f a
forall a. a -> a
id ((a -> b) -> (b -> a) -> g a -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) ((b -> a) -> (a -> b) -> g b -> g a
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> a
g a -> b
f) (p (f a) (g a) -> p (f a) (g b))
-> (Biff p f g a a -> p (f a) (g a))
-> Biff p f g a a
-> p (f a) (g b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Biff p f g a a -> p (f a) (g a)
forall {k1} {k2} {k3} {k4} (p :: k1 -> k2 -> *) (f :: k3 -> k1)
(g :: k4 -> k2) (a :: k3) (b :: k4).
Biff p f g a b -> p (f a) (g b)
runBiff
instance Invariant (Clown f a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Clown f a a -> Clown f a b
invmap = (a -> b) -> (b -> a) -> Clown f a a -> Clown f a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant2 p => Invariant (Fix p) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Fix p a -> Fix p b
invmap a -> b
f b -> a
g = p (Fix p b) b -> Fix p b
forall {k} (p :: * -> k -> *) (a :: k). p (Fix p a) a -> Fix p a
In (p (Fix p b) b -> Fix p b)
-> (Fix p a -> p (Fix p b) b) -> Fix p a -> Fix p b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Fix p a -> Fix p b)
-> (Fix p b -> Fix p a)
-> (a -> b)
-> (b -> a)
-> p (Fix p a) a
-> p (Fix p b) b
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 ((a -> b) -> (b -> a) -> Fix p a -> Fix p b
forall a b. (a -> b) -> (b -> a) -> Fix p a -> Fix p b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) ((b -> a) -> (a -> b) -> Fix p b -> Fix p a
forall a b. (a -> b) -> (b -> a) -> Fix p a -> Fix p b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> a
g a -> b
f) a -> b
f b -> a
g (p (Fix p a) a -> p (Fix p b) b)
-> (Fix p a -> p (Fix p a) a) -> Fix p a -> p (Fix p b) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fix p a -> p (Fix p a) a
forall {k} (p :: * -> k -> *) (a :: k). Fix p a -> p (Fix p a) a
out
instance Invariant2 p => Invariant (Flip p a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Flip p a a -> Flip p a b
invmap = (a -> a)
-> (a -> a) -> (a -> b) -> (b -> a) -> Flip p a a -> Flip p a b
forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Flip p a b -> Flip p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant2 p => Invariant (Join p) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Join p a -> Join p b
invmap a -> b
f b -> a
g = p b b -> Join p b
forall {k} (p :: k -> k -> *) (a :: k). p a a -> Join p a
Join (p b b -> Join p b) -> (Join p a -> p b b) -> Join p a -> Join p b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> (b -> a) -> (a -> b) -> (b -> a) -> p a a -> p b b
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> b
f b -> a
g a -> b
f b -> a
g (p a a -> p b b) -> (Join p a -> p a a) -> Join p a -> p b b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Join p a -> p a a
forall {k} (p :: k -> k -> *) (a :: k). Join p a -> p a a
runJoin
instance Invariant g => Invariant (Joker g a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Joker g a a -> Joker g a b
invmap a -> b
f b -> a
g = g b -> Joker g a b
forall {k} {k1} (g :: k -> *) (a :: k1) (b :: k).
g b -> Joker g a b
Joker (g b -> Joker g a b)
-> (Joker g a a -> g b) -> Joker g a a -> Joker g a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> (b -> a) -> g a -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g (g a -> g b) -> (Joker g a a -> g a) -> Joker g a a -> g b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Joker g a a -> g a
forall {k1} {k2} (g :: k1 -> *) (a :: k2) (b :: k1).
Joker g a b -> g b
runJoker
instance (Invariant f, Invariant2 p) => Invariant (Tannen f p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> Tannen f p a a -> Tannen f p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> Tannen f p a a
-> Tannen f p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Tannen f p a b
-> Tannen f p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Bifunctor p => Invariant (WrappedBifunctor p a) where
invmap :: forall a b.
(a -> b)
-> (b -> a) -> WrappedBifunctor p a a -> WrappedBifunctor p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> WrappedBifunctor p a a
-> WrappedBifunctor p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> WrappedBifunctor p a b
-> WrappedBifunctor p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (Cokleisli w a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> Cokleisli w a a -> Cokleisli w a b
invmap = (a -> b) -> (b -> a) -> Cokleisli w a a -> Cokleisli w a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant IntMap where
invmap :: forall a b. (a -> b) -> (b -> a) -> IntMap a -> IntMap b
invmap = (a -> b) -> (b -> a) -> IntMap a -> IntMap b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant (Map k) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Map k a -> Map k b
invmap = (a -> b) -> (b -> a) -> Map k a -> Map k b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant Seq where
invmap :: forall a b. (a -> b) -> (b -> a) -> Seq a -> Seq b
invmap = (a -> b) -> (b -> a) -> Seq a -> Seq b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant ViewL where
invmap :: forall a b. (a -> b) -> (b -> a) -> ViewL a -> ViewL b
invmap = (a -> b) -> (b -> a) -> ViewL a -> ViewL b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant ViewR where
invmap :: forall a b. (a -> b) -> (b -> a) -> ViewR a -> ViewR b
invmap = (a -> b) -> (b -> a) -> ViewR a -> ViewR b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant Tree where
invmap :: forall a b. (a -> b) -> (b -> a) -> Tree a -> Tree b
invmap = (a -> b) -> (b -> a) -> Tree a -> Tree b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant Predicate where invmap :: forall a b. (a -> b) -> (b -> a) -> Predicate a -> Predicate b
invmap = (a -> b) -> (b -> a) -> Predicate a -> Predicate b
forall (f :: * -> *) a b.
Contravariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapContravariant
instance Invariant Comparison where invmap :: forall a b. (a -> b) -> (b -> a) -> Comparison a -> Comparison b
invmap = (a -> b) -> (b -> a) -> Comparison a -> Comparison b
forall (f :: * -> *) a b.
Contravariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapContravariant
instance Invariant Equivalence where invmap :: forall a b. (a -> b) -> (b -> a) -> Equivalence a -> Equivalence b
invmap = (a -> b) -> (b -> a) -> Equivalence a -> Equivalence b
forall (f :: * -> *) a b.
Contravariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapContravariant
instance Invariant (Op a) where invmap :: forall a b. (a -> b) -> (b -> a) -> Op a a -> Op a b
invmap = (a -> b) -> (b -> a) -> Op a a -> Op a b
forall (f :: * -> *) a b.
Contravariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapContravariant
instance (Invariant f, Invariant g) => Invariant (Contravariant.Compose f g) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Compose f g a -> Compose f g b
invmap a -> b
f b -> a
g (Contravariant.Compose f (g a)
x) =
f (g b) -> Compose f g b
forall (f :: * -> *) (g :: * -> *) a. f (g a) -> Compose f g a
Contravariant.Compose (f (g b) -> Compose f g b) -> f (g b) -> Compose f g b
forall a b. (a -> b) -> a -> b
$ (g a -> g b) -> (g b -> g a) -> f (g a) -> f (g b)
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (b -> a) -> g a -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) ((b -> a) -> (a -> b) -> g b -> g a
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> a
g a -> b
f) f (g a)
x
instance (Invariant f, Invariant g) => Invariant (ComposeCF f g) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> ComposeCF f g a -> ComposeCF f g b
invmap a -> b
f b -> a
g (ComposeCF f (g a)
x) = f (g b) -> ComposeCF f g b
forall (f :: * -> *) (g :: * -> *) a. f (g a) -> ComposeCF f g a
ComposeCF (f (g b) -> ComposeCF f g b) -> f (g b) -> ComposeCF f g b
forall a b. (a -> b) -> a -> b
$ (g a -> g b) -> (g b -> g a) -> f (g a) -> f (g b)
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (b -> a) -> g a -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) ((b -> a) -> (a -> b) -> g b -> g a
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> a
g a -> b
f) f (g a)
x
instance (Invariant f, Invariant g) => Invariant (ComposeFC f g) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> ComposeFC f g a -> ComposeFC f g b
invmap a -> b
f b -> a
g (ComposeFC f (g a)
x) = f (g b) -> ComposeFC f g b
forall (f :: * -> *) (g :: * -> *) a. f (g a) -> ComposeFC f g a
ComposeFC (f (g b) -> ComposeFC f g b) -> f (g b) -> ComposeFC f g b
forall a b. (a -> b) -> a -> b
$ (g a -> g b) -> (g b -> g a) -> f (g a) -> f (g b)
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (b -> a) -> g a -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) ((b -> a) -> (a -> b) -> g b -> g a
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> a
g a -> b
f) f (g a)
x
instance Invariant f => Invariant (Star f a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Star f a a -> Star f a b
invmap = (a -> a)
-> (a -> a) -> (a -> b) -> (b -> a) -> Star f a a -> Star f a b
forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Star f a b -> Star f c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (Costar f a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Costar f a a -> Costar f a b
invmap = (a -> b) -> (b -> a) -> Costar f a a -> Costar f a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Arrow arr => Invariant (Pro.WrappedArrow arr a) where
invmap :: forall a b.
(a -> b)
-> (b -> a) -> WrappedArrow arr a a -> WrappedArrow arr a b
invmap a -> b
f b -> a
_ (Pro.WrapArrow arr a a
x) = arr a b -> WrappedArrow arr a b
forall {k} {k1} (p :: k -> k1 -> *) (a :: k) (b :: k1).
p a b -> WrappedArrow p a b
Pro.WrapArrow (arr a b -> WrappedArrow arr a b)
-> arr a b -> WrappedArrow arr a b
forall a b. (a -> b) -> a -> b
$ (((a -> b) -> arr a b
forall b c. (b -> c) -> arr b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr a -> b
f) arr a b -> arr a a -> arr a b
forall b c a. arr b c -> arr a b -> arr a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
Cat.. arr a a
x)
instance Invariant (Forget r a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Forget r a a -> Forget r a b
invmap = (a -> b) -> (b -> a) -> Forget r a a -> Forget r a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant2 p => Invariant (Closure p a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Closure p a a -> Closure p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> Closure p a a
-> Closure p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Closure p a b
-> Closure p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (Environment p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> Environment p a a -> Environment p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> Environment p a a
-> Environment p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Environment p a b
-> Environment p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant2 p => Invariant (Codensity p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> Codensity p a a -> Codensity p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> Codensity p a a
-> Codensity p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Codensity p a b
-> Codensity p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant2 p => Invariant (Coprep p) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Coprep p a -> Coprep p b
invmap a -> b
f b -> a
g (Coprep forall r. p a r -> r
h) = (forall r. p b r -> r) -> Coprep p b
forall {k} (p :: k -> * -> *) (a :: k).
(forall r. p a r -> r) -> Coprep p a
Coprep (p a r -> r
forall r. p a r -> r
h (p a r -> r) -> (p b r -> p a r) -> p b r -> r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> a) -> (a -> b) -> (r -> r) -> (r -> r) -> p b r -> p a r
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 b -> a
g a -> b
f r -> r
forall a. a -> a
id r -> r
forall a. a -> a
id)
instance Invariant2 p => Invariant (Prep p) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Prep p a -> Prep p b
invmap a -> b
f b -> a
g (Prep x
x p x a
p) = x -> p x b -> Prep p b
forall {k} x (p :: * -> k -> *) (a :: k). x -> p x a -> Prep p a
Prep x
x ((x -> x) -> (x -> x) -> (a -> b) -> (b -> a) -> p x a -> p x b
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id a -> b
f b -> a
g p x a
p)
instance Invariant2 p => Invariant (Procompose p q a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> Procompose p q a a -> Procompose p q a b
invmap a -> b
k b -> a
k' (Procompose p x a
f q a x
g) = p x b -> q a x -> Procompose p q a b
forall {k} {k1} {k2} (p :: k -> k1 -> *) (x :: k) (c :: k1)
(q :: k2 -> k -> *) (d :: k2).
p x c -> q d x -> Procompose p q d c
Procompose ((x -> x) -> (x -> x) -> (a -> b) -> (b -> a) -> p x a -> p x b
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id a -> b
k b -> a
k' p x a
f) q a x
g
instance Invariant2 p => Invariant (Rift p q a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Rift p q a a -> Rift p q a b
invmap a -> b
bd b -> a
db (Rift forall x. p a x -> q a x
f) = (forall x. p b x -> q a x) -> Rift p q a b
forall {k} {k1} {k2} (p :: k -> k1 -> *) (q :: k2 -> k1 -> *)
(a :: k2) (b :: k).
(forall (x :: k1). p b x -> q a x) -> Rift p q a b
Rift (p a x -> q a x
forall x. p a x -> q a x
f (p a x -> q a x) -> (p b x -> p a x) -> p b x -> q a x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> a) -> (a -> b) -> (x -> x) -> (x -> x) -> p b x -> p a x
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 b -> a
db a -> b
bd x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id)
instance Invariant2 q => Invariant (Ran p q a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Ran p q a a -> Ran p q a b
invmap a -> b
bd b -> a
db (Ran forall x. p x a -> q x a
f) = (forall x. p x a -> q x b) -> Ran p q a b
forall {k} {k1} {k2} (p :: k -> k1 -> *) (q :: k -> k2 -> *)
(a :: k1) (b :: k2).
(forall (x :: k). p x a -> q x b) -> Ran p q a b
Ran ((x -> x) -> (x -> x) -> (a -> b) -> (b -> a) -> q x a -> q x b
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> q a b -> q c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id a -> b
bd b -> a
db (q x a -> q x b) -> (p x a -> q x a) -> p x a -> q x b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p x a -> q x a
forall x. p x a -> q x a
f)
instance Invariant2 p => Invariant (Tambara p a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Tambara p a a -> Tambara p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> Tambara p a a
-> Tambara p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Tambara p a b
-> Tambara p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (PastroSum p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> PastroSum p a a -> PastroSum p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> PastroSum p a a
-> PastroSum p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> PastroSum p a b
-> PastroSum p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (FreeMapping p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> FreeMapping p a a -> FreeMapping p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> FreeMapping p a a
-> FreeMapping p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> FreeMapping p a b
-> FreeMapping p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (FreeTraversing p a) where
invmap :: forall a b.
(a -> b)
-> (b -> a) -> FreeTraversing p a a -> FreeTraversing p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> FreeTraversing p a a
-> FreeTraversing p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> FreeTraversing p a b
-> FreeTraversing p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (Pastro p a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Pastro p a a -> Pastro p a b
invmap = (a -> a)
-> (a -> a) -> (a -> b) -> (b -> a) -> Pastro p a a -> Pastro p a b
forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Pastro p a b -> Pastro p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (Cotambara p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> Cotambara p a a -> Cotambara p a b
invmap = (a -> b) -> (b -> a) -> Cotambara p a a -> Cotambara p a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant (Copastro p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> Copastro p a a -> Copastro p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> Copastro p a a
-> Copastro p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Copastro p a b
-> Copastro p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (CopastroSum p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> CopastroSum p a a -> CopastroSum p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> CopastroSum p a a
-> CopastroSum p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> CopastroSum p a b
-> CopastroSum p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (CotambaraSum p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> CotambaraSum p a a -> CotambaraSum p a b
invmap = (a -> b) -> (b -> a) -> CotambaraSum p a a -> CotambaraSum p a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant2 p => Invariant (TambaraSum p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> TambaraSum p a a -> TambaraSum p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> TambaraSum p a a
-> TambaraSum p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> TambaraSum p a b
-> TambaraSum p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant (Yoneda p a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Yoneda p a a -> Yoneda p a b
invmap = (a -> b) -> (b -> a) -> Yoneda p a a -> Yoneda p a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant (Coyoneda p a) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> Coyoneda p a a -> Coyoneda p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> Coyoneda p a a
-> Coyoneda p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Coyoneda p a b
-> Coyoneda p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Invariant StateVar where
invmap :: forall a b. (a -> b) -> (b -> a) -> StateVar a -> StateVar b
invmap a -> b
f b -> a
g (StateVar IO a
ga a -> IO ()
sa) = IO b -> (b -> IO ()) -> StateVar b
forall a. IO a -> (a -> IO ()) -> StateVar a
StateVar ((a -> b) -> IO a -> IO b
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f IO a
ga) ((b -> a) -> (a -> IO ()) -> b -> IO ()
forall a b c. (a -> b) -> (b -> c) -> a -> c
forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap b -> a
g a -> IO ()
sa)
instance Invariant SettableStateVar where
invmap :: forall a b.
(a -> b) -> (b -> a) -> SettableStateVar a -> SettableStateVar b
invmap = (a -> b) -> (b -> a) -> SettableStateVar a -> SettableStateVar b
forall (f :: * -> *) a b.
Contravariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapContravariant
instance Invariant STM where
invmap :: forall a b. (a -> b) -> (b -> a) -> STM a -> STM b
invmap = (a -> b) -> (b -> a) -> STM a -> STM b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant (Tagged s) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Tagged s a -> Tagged s b
invmap = (a -> b) -> (b -> a) -> Tagged s a -> Tagged s b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant f => Invariant (Backwards f) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Backwards f a -> Backwards f b
invmap a -> b
f b -> a
g (Backwards f a
a) = f b -> Backwards f b
forall {k} (f :: k -> *) (a :: k). f a -> Backwards f a
Backwards ((a -> b) -> (b -> a) -> f a -> f b
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g f a
a)
instance Invariant f => Invariant (Lift f) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Lift f a -> Lift f b
invmap a -> b
f b -> a
_ (Pure a
x) = b -> Lift f b
forall (f :: * -> *) a. a -> Lift f a
Pure (a -> b
f a
x)
invmap a -> b
f b -> a
g (Other f a
y) = f b -> Lift f b
forall (f :: * -> *) a. f a -> Lift f a
Other ((a -> b) -> (b -> a) -> f a -> f b
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g f a
y)
instance Invariant (ContT r m) where
invmap :: forall a b. (a -> b) -> (b -> a) -> ContT r m a -> ContT r m b
invmap = (a -> b) -> (b -> a) -> ContT r m a -> ContT r m b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant m => Invariant (ExceptT e m) where
invmap :: forall a b. (a -> b) -> (b -> a) -> ExceptT e m a -> ExceptT e m b
invmap a -> b
f b -> a
g = m (Either e b) -> ExceptT e m b
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e b) -> ExceptT e m b)
-> (ExceptT e m a -> m (Either e b))
-> ExceptT e m a
-> ExceptT e m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Either e a -> Either e b)
-> (Either e b -> Either e a) -> m (Either e a) -> m (Either e b)
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (b -> a) -> Either e a -> Either e b
forall a b. (a -> b) -> (b -> a) -> Either e a -> Either e b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) ((b -> a) -> (a -> b) -> Either e b -> Either e a
forall a b. (a -> b) -> (b -> a) -> Either e a -> Either e b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> a
g a -> b
f) (m (Either e a) -> m (Either e b))
-> (ExceptT e m a -> m (Either e a))
-> ExceptT e m a
-> m (Either e b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExceptT e m a -> m (Either e a)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT
instance Invariant m => Invariant (IdentityT m) where
invmap :: forall a b. (a -> b) -> (b -> a) -> IdentityT m a -> IdentityT m b
invmap a -> b
f b -> a
g = (m a -> m b) -> IdentityT m a -> IdentityT m b
forall {k1} {k2} (m :: k1 -> *) (a :: k1) (n :: k2 -> *) (b :: k2).
(m a -> n b) -> IdentityT m a -> IdentityT n b
mapIdentityT ((a -> b) -> (b -> a) -> m a -> m b
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g)
instance Invariant m => Invariant (MaybeT m) where
invmap :: forall a b. (a -> b) -> (b -> a) -> MaybeT m a -> MaybeT m b
invmap a -> b
f b -> a
g = (m (Maybe a) -> m (Maybe b)) -> MaybeT m a -> MaybeT m b
forall (m :: * -> *) a (n :: * -> *) b.
(m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b
mapMaybeT ((m (Maybe a) -> m (Maybe b)) -> MaybeT m a -> MaybeT m b)
-> (m (Maybe a) -> m (Maybe b)) -> MaybeT m a -> MaybeT m b
forall a b. (a -> b) -> a -> b
$ (Maybe a -> Maybe b)
-> (Maybe b -> Maybe a) -> m (Maybe a) -> m (Maybe b)
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (b -> a) -> Maybe a -> Maybe b
forall a b. (a -> b) -> (b -> a) -> Maybe a -> Maybe b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) ((b -> a) -> (a -> b) -> Maybe b -> Maybe a
forall a b. (a -> b) -> (b -> a) -> Maybe a -> Maybe b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> a
g a -> b
f)
instance Invariant m => Invariant (Lazy.RWST r w s m) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> RWST r w s m a -> RWST r w s m b
invmap a -> b
f b -> a
g RWST r w s m a
m = (r -> s -> m (b, s, w)) -> RWST r w s m b
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST ((r -> s -> m (b, s, w)) -> RWST r w s m b)
-> (r -> s -> m (b, s, w)) -> RWST r w s m b
forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
((a, s, w) -> (b, s, w))
-> ((b, s, w) -> (a, s, w)) -> m (a, s, w) -> m (b, s, w)
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (a, s, w) -> (b, s, w)
forall a b c d. (a -> b) -> (a, c, d) -> (b, c, d)
mapFstTriple a -> b
f) ((b -> a) -> (b, s, w) -> (a, s, w)
forall a b c d. (a -> b) -> (a, c, d) -> (b, c, d)
mapFstTriple b -> a
g) (m (a, s, w) -> m (b, s, w)) -> m (a, s, w) -> m (b, s, w)
forall a b. (a -> b) -> a -> b
$ RWST r w s m a -> r -> s -> m (a, s, w)
forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST RWST r w s m a
m r
r s
s
where mapFstTriple :: (a -> b) -> (a, c, d) -> (b, c, d)
mapFstTriple :: forall a b c d. (a -> b) -> (a, c, d) -> (b, c, d)
mapFstTriple a -> b
h ~(a
a, c
s, d
w) = (a -> b
h a
a, c
s, d
w)
instance Invariant m => Invariant (Strict.RWST r w s m) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> RWST r w s m a -> RWST r w s m b
invmap a -> b
f b -> a
g RWST r w s m a
m = (r -> s -> m (b, s, w)) -> RWST r w s m b
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST ((r -> s -> m (b, s, w)) -> RWST r w s m b)
-> (r -> s -> m (b, s, w)) -> RWST r w s m b
forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
((a, s, w) -> (b, s, w))
-> ((b, s, w) -> (a, s, w)) -> m (a, s, w) -> m (b, s, w)
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (a, s, w) -> (b, s, w)
forall a b c d. (a -> b) -> (a, c, d) -> (b, c, d)
mapFstTriple a -> b
f) ((b -> a) -> (b, s, w) -> (a, s, w)
forall a b c d. (a -> b) -> (a, c, d) -> (b, c, d)
mapFstTriple b -> a
g) (m (a, s, w) -> m (b, s, w)) -> m (a, s, w) -> m (b, s, w)
forall a b. (a -> b) -> a -> b
$ RWST r w s m a -> r -> s -> m (a, s, w)
forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST RWST r w s m a
m r
r s
s
where mapFstTriple :: (a -> b) -> (a, c, d) -> (b, c, d)
mapFstTriple :: forall a b c d. (a -> b) -> (a, c, d) -> (b, c, d)
mapFstTriple a -> b
h (a
a, c
s, d
w) = (a -> b
h a
a, c
s, d
w)
instance Invariant m => Invariant (ReaderT r m) where
invmap :: forall a b. (a -> b) -> (b -> a) -> ReaderT r m a -> ReaderT r m b
invmap a -> b
f b -> a
g = (m a -> m b) -> ReaderT r m a -> ReaderT r m b
forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT ((a -> b) -> (b -> a) -> m a -> m b
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g)
instance Invariant m => Invariant (Lazy.StateT s m) where
invmap :: forall a b. (a -> b) -> (b -> a) -> StateT s m a -> StateT s m b
invmap a -> b
f b -> a
g StateT s m a
m = (s -> m (b, s)) -> StateT s m b
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT ((s -> m (b, s)) -> StateT s m b)
-> (s -> m (b, s)) -> StateT s m b
forall a b. (a -> b) -> a -> b
$ \s
s ->
((a, s) -> (b, s)) -> ((b, s) -> (a, s)) -> m (a, s) -> m (b, s)
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (a, s) -> (b, s)
forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair a -> b
f) ((b -> a) -> (b, s) -> (a, s)
forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair b -> a
g) (m (a, s) -> m (b, s)) -> m (a, s) -> m (b, s)
forall a b. (a -> b) -> a -> b
$ StateT s m a -> s -> m (a, s)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT StateT s m a
m s
s
where mapFstPair :: (a -> b) -> (a, c) -> (b, c)
mapFstPair :: forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair a -> b
h ~(a
a, c
s) = (a -> b
h a
a, c
s)
instance Invariant m => Invariant (Strict.StateT s m) where
invmap :: forall a b. (a -> b) -> (b -> a) -> StateT s m a -> StateT s m b
invmap a -> b
f b -> a
g StateT s m a
m = (s -> m (b, s)) -> StateT s m b
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT ((s -> m (b, s)) -> StateT s m b)
-> (s -> m (b, s)) -> StateT s m b
forall a b. (a -> b) -> a -> b
$ \s
s ->
((a, s) -> (b, s)) -> ((b, s) -> (a, s)) -> m (a, s) -> m (b, s)
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (a, s) -> (b, s)
forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair a -> b
f) ((b -> a) -> (b, s) -> (a, s)
forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair b -> a
g) (m (a, s) -> m (b, s)) -> m (a, s) -> m (b, s)
forall a b. (a -> b) -> a -> b
$ StateT s m a -> s -> m (a, s)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT StateT s m a
m s
s
where mapFstPair :: (a -> b) -> (a, c) -> (b, c)
mapFstPair :: forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair a -> b
h (a
a, c
s) = (a -> b
h a
a, c
s)
instance Invariant m => Invariant (Lazy.WriterT w m) where
invmap :: forall a b. (a -> b) -> (b -> a) -> WriterT w m a -> WriterT w m b
invmap a -> b
f b -> a
g = (m (a, w) -> m (b, w)) -> WriterT w m a -> WriterT w m b
forall (m :: * -> *) a w (n :: * -> *) b w'.
(m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
Lazy.mapWriterT ((m (a, w) -> m (b, w)) -> WriterT w m a -> WriterT w m b)
-> (m (a, w) -> m (b, w)) -> WriterT w m a -> WriterT w m b
forall a b. (a -> b) -> a -> b
$ ((a, w) -> (b, w)) -> ((b, w) -> (a, w)) -> m (a, w) -> m (b, w)
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (a, w) -> (b, w)
forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair a -> b
f) ((b -> a) -> (b, w) -> (a, w)
forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair b -> a
g)
where mapFstPair :: (a -> b) -> (a, c) -> (b, c)
mapFstPair :: forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair a -> b
h ~(a
a, c
w) = (a -> b
h a
a, c
w)
instance Invariant m => Invariant (Strict.WriterT w m) where
invmap :: forall a b. (a -> b) -> (b -> a) -> WriterT w m a -> WriterT w m b
invmap a -> b
f b -> a
g = (m (a, w) -> m (b, w)) -> WriterT w m a -> WriterT w m b
forall (m :: * -> *) a w (n :: * -> *) b w'.
(m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
Strict.mapWriterT ((m (a, w) -> m (b, w)) -> WriterT w m a -> WriterT w m b)
-> (m (a, w) -> m (b, w)) -> WriterT w m a -> WriterT w m b
forall a b. (a -> b) -> a -> b
$ ((a, w) -> (b, w)) -> ((b, w) -> (a, w)) -> m (a, w) -> m (b, w)
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (a, w) -> (b, w)
forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair a -> b
f) ((b -> a) -> (b, w) -> (a, w)
forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair b -> a
g)
where mapFstPair :: (a -> b) -> (a, c) -> (b, c)
mapFstPair :: forall a b c. (a -> b) -> (a, c) -> (b, c)
mapFstPair a -> b
h (a
a, c
w) = (a -> b
h a
a, c
w)
instance Invariant (Constant a) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Constant a a -> Constant a b
invmap = (a -> b) -> (b -> a) -> Constant a a -> Constant a b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Invariant f => Invariant (Reverse f) where
invmap :: forall a b. (a -> b) -> (b -> a) -> Reverse f a -> Reverse f b
invmap a -> b
f b -> a
g (Reverse f a
a) = f b -> Reverse f b
forall {k} (f :: k -> *) (a :: k). f a -> Reverse f a
Reverse ((a -> b) -> (b -> a) -> f a -> f b
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g f a
a)
#if !(MIN_VERSION_transformers(0,6,0))
instance Invariant m => Invariant (ErrorT e m) where
invmap f g = ErrorT . invmap (invmap f g) (invmap g f) . runErrorT
instance Invariant m => Invariant (ListT m) where
invmap f g = mapListT $ invmap (invmap f g) (invmap g f)
#endif
instance Invariant (HashMap k) where
invmap :: forall a b. (a -> b) -> (b -> a) -> HashMap k a -> HashMap k b
invmap = (a -> b) -> (b -> a) -> HashMap k a -> HashMap k b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
newtype WrappedFunctor f a = WrapFunctor { forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor :: f a }
deriving (WrappedFunctor f a -> WrappedFunctor f a -> Bool
(WrappedFunctor f a -> WrappedFunctor f a -> Bool)
-> (WrappedFunctor f a -> WrappedFunctor f a -> Bool)
-> Eq (WrappedFunctor f a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (f :: k -> *) (a :: k).
Eq (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Bool
$c== :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Bool
== :: WrappedFunctor f a -> WrappedFunctor f a -> Bool
$c/= :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Bool
/= :: WrappedFunctor f a -> WrappedFunctor f a -> Bool
Eq, Eq (WrappedFunctor f a)
Eq (WrappedFunctor f a) =>
(WrappedFunctor f a -> WrappedFunctor f a -> Ordering)
-> (WrappedFunctor f a -> WrappedFunctor f a -> Bool)
-> (WrappedFunctor f a -> WrappedFunctor f a -> Bool)
-> (WrappedFunctor f a -> WrappedFunctor f a -> Bool)
-> (WrappedFunctor f a -> WrappedFunctor f a -> Bool)
-> (WrappedFunctor f a -> WrappedFunctor f a -> WrappedFunctor f a)
-> (WrappedFunctor f a -> WrappedFunctor f a -> WrappedFunctor f a)
-> Ord (WrappedFunctor f a)
WrappedFunctor f a -> WrappedFunctor f a -> Bool
WrappedFunctor f a -> WrappedFunctor f a -> Ordering
WrappedFunctor f a -> WrappedFunctor f a -> WrappedFunctor f a
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
Eq (WrappedFunctor f a)
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Bool
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Ordering
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> WrappedFunctor f a
$ccompare :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Ordering
compare :: WrappedFunctor f a -> WrappedFunctor f a -> Ordering
$c< :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Bool
< :: WrappedFunctor f a -> WrappedFunctor f a -> Bool
$c<= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Bool
<= :: WrappedFunctor f a -> WrappedFunctor f a -> Bool
$c> :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Bool
> :: WrappedFunctor f a -> WrappedFunctor f a -> Bool
$c>= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> Bool
>= :: WrappedFunctor f a -> WrappedFunctor f a -> Bool
$cmax :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> WrappedFunctor f a
max :: WrappedFunctor f a -> WrappedFunctor f a -> WrappedFunctor f a
$cmin :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedFunctor f a -> WrappedFunctor f a -> WrappedFunctor f a
min :: WrappedFunctor f a -> WrappedFunctor f a -> WrappedFunctor f a
Ord, ReadPrec [WrappedFunctor f a]
ReadPrec (WrappedFunctor f a)
Int -> ReadS (WrappedFunctor f a)
ReadS [WrappedFunctor f a]
(Int -> ReadS (WrappedFunctor f a))
-> ReadS [WrappedFunctor f a]
-> ReadPrec (WrappedFunctor f a)
-> ReadPrec [WrappedFunctor f a]
-> Read (WrappedFunctor f a)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [WrappedFunctor f a]
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (WrappedFunctor f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (WrappedFunctor f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadS [WrappedFunctor f a]
$creadsPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (WrappedFunctor f a)
readsPrec :: Int -> ReadS (WrappedFunctor f a)
$creadList :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadS [WrappedFunctor f a]
readList :: ReadS [WrappedFunctor f a]
$creadPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (WrappedFunctor f a)
readPrec :: ReadPrec (WrappedFunctor f a)
$creadListPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [WrappedFunctor f a]
readListPrec :: ReadPrec [WrappedFunctor f a]
Read, Int -> WrappedFunctor f a -> ShowS
[WrappedFunctor f a] -> ShowS
WrappedFunctor f a -> String
(Int -> WrappedFunctor f a -> ShowS)
-> (WrappedFunctor f a -> String)
-> ([WrappedFunctor f a] -> ShowS)
-> Show (WrappedFunctor f a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> WrappedFunctor f a -> ShowS
forall k (f :: k -> *) (a :: k).
Show (f a) =>
[WrappedFunctor f a] -> ShowS
forall k (f :: k -> *) (a :: k).
Show (f a) =>
WrappedFunctor f a -> String
$cshowsPrec :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> WrappedFunctor f a -> ShowS
showsPrec :: Int -> WrappedFunctor f a -> ShowS
$cshow :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
WrappedFunctor f a -> String
show :: WrappedFunctor f a -> String
$cshowList :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
[WrappedFunctor f a] -> ShowS
showList :: [WrappedFunctor f a] -> ShowS
Show)
instance Functor f => Invariant (WrappedFunctor f) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> WrappedFunctor f a -> WrappedFunctor f b
invmap = (a -> b) -> (b -> a) -> WrappedFunctor f a -> WrappedFunctor f b
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapFunctor
instance Functor f => Functor (WrappedFunctor f) where
fmap :: forall a b. (a -> b) -> WrappedFunctor f a -> WrappedFunctor f b
fmap a -> b
f = f b -> WrappedFunctor f b
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f b -> WrappedFunctor f b)
-> (WrappedFunctor f a -> f b)
-> WrappedFunctor f a
-> WrappedFunctor f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> f a -> f b
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (f a -> f b)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
a
x <$ :: forall a b. a -> WrappedFunctor f b -> WrappedFunctor f a
<$ WrapFunctor f b
f = f a -> WrappedFunctor f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (a
x a -> f b -> f a
forall a b. a -> f b -> f a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ f b
f)
instance Applicative f => Applicative (WrappedFunctor f) where
pure :: forall a. a -> WrappedFunctor f a
pure = f a -> WrappedFunctor f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f a -> WrappedFunctor f a)
-> (a -> f a) -> a -> WrappedFunctor f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f a
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
WrapFunctor f (a -> b)
f <*> :: forall a b.
WrappedFunctor f (a -> b)
-> WrappedFunctor f a -> WrappedFunctor f b
<*> WrapFunctor f a
x = f b -> WrappedFunctor f b
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f (a -> b)
f f (a -> b) -> f a -> f b
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
x)
WrapFunctor f a
a *> :: forall a b.
WrappedFunctor f a -> WrappedFunctor f b -> WrappedFunctor f b
*> WrapFunctor f b
b = f b -> WrappedFunctor f b
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f a
a f a -> f b -> f b
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> f b
b)
WrapFunctor f a
a <* :: forall a b.
WrappedFunctor f a -> WrappedFunctor f b -> WrappedFunctor f a
<* WrapFunctor f b
b = f a -> WrappedFunctor f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f a
a f a -> f b -> f a
forall a b. f a -> f b -> f a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* f b
b)
instance Alternative f => Alternative (WrappedFunctor f) where
empty :: forall a. WrappedFunctor f a
empty = f a -> WrappedFunctor f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor f a
forall a. f a
forall (f :: * -> *) a. Alternative f => f a
empty
WrapFunctor f a
x <|> :: forall a.
WrappedFunctor f a -> WrappedFunctor f a -> WrappedFunctor f a
<|> WrapFunctor f a
y = f a -> WrappedFunctor f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f a
x f a -> f a -> f a
forall a. f a -> f a -> f a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> f a
y)
some :: forall a. WrappedFunctor f a -> WrappedFunctor f [a]
some = f [a] -> WrappedFunctor f [a]
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f [a] -> WrappedFunctor f [a])
-> (WrappedFunctor f a -> f [a])
-> WrappedFunctor f a
-> WrappedFunctor f [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> f [a]
forall a. f a -> f [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (f a -> f [a])
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> f [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
many :: forall a. WrappedFunctor f a -> WrappedFunctor f [a]
many = f [a] -> WrappedFunctor f [a]
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f [a] -> WrappedFunctor f [a])
-> (WrappedFunctor f a -> f [a])
-> WrappedFunctor f a
-> WrappedFunctor f [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> f [a]
forall a. f a -> f [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (f a -> f [a])
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> f [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
instance Monad m => Monad (WrappedFunctor m) where
WrapFunctor m a
x >>= :: forall a b.
WrappedFunctor m a
-> (a -> WrappedFunctor m b) -> WrappedFunctor m b
>>= a -> WrappedFunctor m b
f = m b -> WrappedFunctor m b
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (m a
x m a -> (a -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= WrappedFunctor m b -> m b
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor (WrappedFunctor m b -> m b)
-> (a -> WrappedFunctor m b) -> a -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> WrappedFunctor m b
f)
#if !(MIN_VERSION_base(4,11,0))
return = WrapFunctor . return
WrapFunctor a >> WrapFunctor b = WrapFunctor (a >> b)
#endif
instance MonadPlus m => MonadPlus (WrappedFunctor m) where
mzero :: forall a. WrappedFunctor m a
mzero = m a -> WrappedFunctor m a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor m a
forall a. m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
WrapFunctor m a
x mplus :: forall a.
WrappedFunctor m a -> WrappedFunctor m a -> WrappedFunctor m a
`mplus` WrapFunctor m a
y = m a -> WrappedFunctor m a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (m a
x m a -> m a -> m a
forall a. m a -> m a -> m a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` m a
y)
instance F.Foldable f => F.Foldable (WrappedFunctor f) where
fold :: forall m. Monoid m => WrappedFunctor f m -> m
fold = f m -> m
forall m. Monoid m => f m -> m
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
F.fold (f m -> m)
-> (WrappedFunctor f m -> f m) -> WrappedFunctor f m -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f m -> f m
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
foldMap :: forall m a. Monoid m => (a -> m) -> WrappedFunctor f a -> m
foldMap a -> m
f = (a -> m) -> f a -> m
forall m a. Monoid m => (a -> m) -> f a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap a -> m
f (f a -> m)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
foldr :: forall a b. (a -> b -> b) -> b -> WrappedFunctor f a -> b
foldr a -> b -> b
f b
z = (a -> b -> b) -> b -> f a -> b
forall a b. (a -> b -> b) -> b -> f a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr a -> b -> b
f b
z (f a -> b)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
foldl :: forall b a. (b -> a -> b) -> b -> WrappedFunctor f a -> b
foldl b -> a -> b
f b
q = (b -> a -> b) -> b -> f a -> b
forall b a. (b -> a -> b) -> b -> f a -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl b -> a -> b
f b
q (f a -> b)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
foldr1 :: forall a. (a -> a -> a) -> WrappedFunctor f a -> a
foldr1 a -> a -> a
f = (a -> a -> a) -> f a -> a
forall a. (a -> a -> a) -> f a -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
F.foldr1 a -> a -> a
f (f a -> a)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
foldl1 :: forall a. (a -> a -> a) -> WrappedFunctor f a -> a
foldl1 a -> a -> a
f = (a -> a -> a) -> f a -> a
forall a. (a -> a -> a) -> f a -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
F.foldl1 a -> a -> a
f (f a -> a)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
#if MIN_VERSION_base(4,6,0)
foldr' :: forall a b. (a -> b -> b) -> b -> WrappedFunctor f a -> b
foldr' a -> b -> b
f b
z = (a -> b -> b) -> b -> f a -> b
forall a b. (a -> b -> b) -> b -> f a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr' a -> b -> b
f b
z (f a -> b)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
foldl' :: forall b a. (b -> a -> b) -> b -> WrappedFunctor f a -> b
foldl' b -> a -> b
f b
q = (b -> a -> b) -> b -> f a -> b
forall b a. (b -> a -> b) -> b -> f a -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl' b -> a -> b
f b
q (f a -> b)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
#endif
#if MIN_VERSION_base(4,8,0)
toList :: forall a. WrappedFunctor f a -> [a]
toList = f a -> [a]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList (f a -> [a])
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
null :: forall a. WrappedFunctor f a -> Bool
null = f a -> Bool
forall a. f a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null (f a -> Bool)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
length :: forall a. WrappedFunctor f a -> Int
length = f a -> Int
forall a. f a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
F.length (f a -> Int)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
elem :: forall a. Eq a => a -> WrappedFunctor f a -> Bool
elem a
x = a -> f a -> Bool
forall a. Eq a => a -> f a -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
F.elem a
x (f a -> Bool)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
maximum :: forall a. Ord a => WrappedFunctor f a -> a
maximum = f a -> a
forall a. Ord a => f a -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
F.maximum (f a -> a)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
minimum :: forall a. Ord a => WrappedFunctor f a -> a
minimum = f a -> a
forall a. Ord a => f a -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
F.minimum (f a -> a)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
sum :: forall a. Num a => WrappedFunctor f a -> a
sum = f a -> a
forall a. Num a => f a -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
F.sum (f a -> a)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
product :: forall a. Num a => WrappedFunctor f a -> a
product = f a -> a
forall a. Num a => f a -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
F.product (f a -> a)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
#endif
#if MIN_VERSION_base(4,13,0)
foldMap' :: forall m a. Monoid m => (a -> m) -> WrappedFunctor f a -> m
foldMap' a -> m
f = (a -> m) -> f a -> m
forall m a. Monoid m => (a -> m) -> f a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap' a -> m
f (f a -> m)
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
#endif
instance T.Traversable f => T.Traversable (WrappedFunctor f) where
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WrappedFunctor f a -> f (WrappedFunctor f b)
traverse a -> f b
f = (f b -> WrappedFunctor f b) -> f (f b) -> f (WrappedFunctor f b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap f b -> WrappedFunctor f b
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f (f b) -> f (WrappedFunctor f b))
-> (WrappedFunctor f a -> f (f b))
-> WrappedFunctor f a
-> f (WrappedFunctor f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f b) -> f a -> f (f b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> f a -> f (f b)
T.traverse a -> f b
f (f a -> f (f b))
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> f (f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
WrappedFunctor f (f a) -> f (WrappedFunctor f a)
sequenceA = (f a -> WrappedFunctor f a) -> f (f a) -> f (WrappedFunctor f a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap f a -> WrappedFunctor f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (f (f a) -> f (WrappedFunctor f a))
-> (WrappedFunctor f (f a) -> f (f a))
-> WrappedFunctor f (f a)
-> f (WrappedFunctor f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (f a) -> f (f a)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => f (f a) -> f (f a)
T.sequenceA (f (f a) -> f (f a))
-> (WrappedFunctor f (f a) -> f (f a))
-> WrappedFunctor f (f a)
-> f (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f (f a) -> f (f a)
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WrappedFunctor f a -> m (WrappedFunctor f b)
mapM a -> m b
f = (f b -> WrappedFunctor f b) -> m (f b) -> m (WrappedFunctor f b)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM f b -> WrappedFunctor f b
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (m (f b) -> m (WrappedFunctor f b))
-> (WrappedFunctor f a -> m (f b))
-> WrappedFunctor f a
-> m (WrappedFunctor f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> m b) -> f a -> m (f b)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> f a -> m (f b)
T.mapM a -> m b
f (f a -> m (f b))
-> (WrappedFunctor f a -> f a) -> WrappedFunctor f a -> m (f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
sequence :: forall (m :: * -> *) a.
Monad m =>
WrappedFunctor f (m a) -> m (WrappedFunctor f a)
sequence = (f a -> WrappedFunctor f a) -> m (f a) -> m (WrappedFunctor f a)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM f a -> WrappedFunctor f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedFunctor f a
WrapFunctor (m (f a) -> m (WrappedFunctor f a))
-> (WrappedFunctor f (m a) -> m (f a))
-> WrappedFunctor f (m a)
-> m (WrappedFunctor f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (m a) -> m (f a)
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => f (m a) -> m (f a)
T.sequence (f (m a) -> m (f a))
-> (WrappedFunctor f (m a) -> f (m a))
-> WrappedFunctor f (m a)
-> m (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedFunctor f (m a) -> f (m a)
forall {k} (f :: k -> *) (a :: k). WrappedFunctor f a -> f a
unwrapFunctor
newtype WrappedContravariant f a = WrapContravariant { forall {k} (f :: k -> *) (a :: k). WrappedContravariant f a -> f a
unwrapContravariant :: f a }
deriving (WrappedContravariant f a -> WrappedContravariant f a -> Bool
(WrappedContravariant f a -> WrappedContravariant f a -> Bool)
-> (WrappedContravariant f a -> WrappedContravariant f a -> Bool)
-> Eq (WrappedContravariant f a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (f :: k -> *) (a :: k).
Eq (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Bool
$c== :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Bool
== :: WrappedContravariant f a -> WrappedContravariant f a -> Bool
$c/= :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Bool
/= :: WrappedContravariant f a -> WrappedContravariant f a -> Bool
Eq, Eq (WrappedContravariant f a)
Eq (WrappedContravariant f a) =>
(WrappedContravariant f a -> WrappedContravariant f a -> Ordering)
-> (WrappedContravariant f a -> WrappedContravariant f a -> Bool)
-> (WrappedContravariant f a -> WrappedContravariant f a -> Bool)
-> (WrappedContravariant f a -> WrappedContravariant f a -> Bool)
-> (WrappedContravariant f a -> WrappedContravariant f a -> Bool)
-> (WrappedContravariant f a
-> WrappedContravariant f a -> WrappedContravariant f a)
-> (WrappedContravariant f a
-> WrappedContravariant f a -> WrappedContravariant f a)
-> Ord (WrappedContravariant f a)
WrappedContravariant f a -> WrappedContravariant f a -> Bool
WrappedContravariant f a -> WrappedContravariant f a -> Ordering
WrappedContravariant f a
-> WrappedContravariant f a -> WrappedContravariant f a
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
Eq (WrappedContravariant f a)
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Bool
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Ordering
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a
-> WrappedContravariant f a -> WrappedContravariant f a
$ccompare :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Ordering
compare :: WrappedContravariant f a -> WrappedContravariant f a -> Ordering
$c< :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Bool
< :: WrappedContravariant f a -> WrappedContravariant f a -> Bool
$c<= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Bool
<= :: WrappedContravariant f a -> WrappedContravariant f a -> Bool
$c> :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Bool
> :: WrappedContravariant f a -> WrappedContravariant f a -> Bool
$c>= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a -> WrappedContravariant f a -> Bool
>= :: WrappedContravariant f a -> WrappedContravariant f a -> Bool
$cmax :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a
-> WrappedContravariant f a -> WrappedContravariant f a
max :: WrappedContravariant f a
-> WrappedContravariant f a -> WrappedContravariant f a
$cmin :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
WrappedContravariant f a
-> WrappedContravariant f a -> WrappedContravariant f a
min :: WrappedContravariant f a
-> WrappedContravariant f a -> WrappedContravariant f a
Ord, ReadPrec [WrappedContravariant f a]
ReadPrec (WrappedContravariant f a)
Int -> ReadS (WrappedContravariant f a)
ReadS [WrappedContravariant f a]
(Int -> ReadS (WrappedContravariant f a))
-> ReadS [WrappedContravariant f a]
-> ReadPrec (WrappedContravariant f a)
-> ReadPrec [WrappedContravariant f a]
-> Read (WrappedContravariant f a)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [WrappedContravariant f a]
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (WrappedContravariant f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (WrappedContravariant f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadS [WrappedContravariant f a]
$creadsPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (WrappedContravariant f a)
readsPrec :: Int -> ReadS (WrappedContravariant f a)
$creadList :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadS [WrappedContravariant f a]
readList :: ReadS [WrappedContravariant f a]
$creadPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (WrappedContravariant f a)
readPrec :: ReadPrec (WrappedContravariant f a)
$creadListPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [WrappedContravariant f a]
readListPrec :: ReadPrec [WrappedContravariant f a]
Read, Int -> WrappedContravariant f a -> ShowS
[WrappedContravariant f a] -> ShowS
WrappedContravariant f a -> String
(Int -> WrappedContravariant f a -> ShowS)
-> (WrappedContravariant f a -> String)
-> ([WrappedContravariant f a] -> ShowS)
-> Show (WrappedContravariant f a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> WrappedContravariant f a -> ShowS
forall k (f :: k -> *) (a :: k).
Show (f a) =>
[WrappedContravariant f a] -> ShowS
forall k (f :: k -> *) (a :: k).
Show (f a) =>
WrappedContravariant f a -> String
$cshowsPrec :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> WrappedContravariant f a -> ShowS
showsPrec :: Int -> WrappedContravariant f a -> ShowS
$cshow :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
WrappedContravariant f a -> String
show :: WrappedContravariant f a -> String
$cshowList :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
[WrappedContravariant f a] -> ShowS
showList :: [WrappedContravariant f a] -> ShowS
Show)
instance Contravariant f => Invariant (WrappedContravariant f) where
invmap :: forall a b.
(a -> b)
-> (b -> a) -> WrappedContravariant f a -> WrappedContravariant f b
invmap = (a -> b)
-> (b -> a) -> WrappedContravariant f a -> WrappedContravariant f b
forall (f :: * -> *) a b.
Contravariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmapContravariant
instance Contravariant f => Contravariant (WrappedContravariant f) where
contramap :: forall a' a.
(a' -> a) -> WrappedContravariant f a -> WrappedContravariant f a'
contramap a' -> a
f = f a' -> WrappedContravariant f a'
forall {k} (f :: k -> *) (a :: k). f a -> WrappedContravariant f a
WrapContravariant (f a' -> WrappedContravariant f a')
-> (WrappedContravariant f a -> f a')
-> WrappedContravariant f a
-> WrappedContravariant f a'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a' -> a) -> f a -> f a'
forall a' a. (a' -> a) -> f a -> f a'
forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap a' -> a
f (f a -> f a')
-> (WrappedContravariant f a -> f a)
-> WrappedContravariant f a
-> f a'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedContravariant f a -> f a
forall {k} (f :: k -> *) (a :: k). WrappedContravariant f a -> f a
unwrapContravariant
b
x >$ :: forall b a.
b -> WrappedContravariant f b -> WrappedContravariant f a
>$ WrapContravariant f b
f = f a -> WrappedContravariant f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedContravariant f a
WrapContravariant (b
x b -> f b -> f a
forall b a. b -> f b -> f a
forall (f :: * -> *) b a. Contravariant f => b -> f b -> f a
>$ f b
f)
instance Divisible f => Divisible (WrappedContravariant f) where
divide :: forall a b c.
(a -> (b, c))
-> WrappedContravariant f b
-> WrappedContravariant f c
-> WrappedContravariant f a
divide a -> (b, c)
f (WrapContravariant f b
l) (WrapContravariant f c
r) =
f a -> WrappedContravariant f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedContravariant f a
WrapContravariant (f a -> WrappedContravariant f a)
-> f a -> WrappedContravariant f a
forall a b. (a -> b) -> a -> b
$ (a -> (b, c)) -> f b -> f c -> f a
forall a b c. (a -> (b, c)) -> f b -> f c -> f a
forall (f :: * -> *) a b c.
Divisible f =>
(a -> (b, c)) -> f b -> f c -> f a
divide a -> (b, c)
f f b
l f c
r
conquer :: forall a. WrappedContravariant f a
conquer = f a -> WrappedContravariant f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedContravariant f a
WrapContravariant f a
forall a. f a
forall (f :: * -> *) a. Divisible f => f a
conquer
instance Decidable f => Decidable (WrappedContravariant f) where
lose :: forall a. (a -> Void) -> WrappedContravariant f a
lose = f a -> WrappedContravariant f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedContravariant f a
WrapContravariant (f a -> WrappedContravariant f a)
-> ((a -> Void) -> f a) -> (a -> Void) -> WrappedContravariant f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Void) -> f a
forall a. (a -> Void) -> f a
forall (f :: * -> *) a. Decidable f => (a -> Void) -> f a
lose
choose :: forall a b c.
(a -> Either b c)
-> WrappedContravariant f b
-> WrappedContravariant f c
-> WrappedContravariant f a
choose a -> Either b c
f (WrapContravariant f b
l) (WrapContravariant f c
r) =
f a -> WrappedContravariant f a
forall {k} (f :: k -> *) (a :: k). f a -> WrappedContravariant f a
WrapContravariant (f a -> WrappedContravariant f a)
-> f a -> WrappedContravariant f a
forall a b. (a -> b) -> a -> b
$ (a -> Either b c) -> f b -> f c -> f a
forall a b c. (a -> Either b c) -> f b -> f c -> f a
forall (f :: * -> *) a b c.
Decidable f =>
(a -> Either b c) -> f b -> f c -> f a
choose a -> Either b c
f f b
l f c
r
class Invariant2 f where
invmap2 :: (a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Bifunctor :: Bifunctor f
=> (a -> c) -> (c -> a)
-> (b -> d) -> (d -> b)
-> f a b -> f c d
invmap2Bifunctor :: forall (f :: * -> * -> *) a c b d.
Bifunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Bifunctor a -> c
f c -> a
_ b -> d
g d -> b
_ = (a -> c) -> (b -> d) -> f a b -> f c d
forall a b c d. (a -> b) -> (c -> d) -> f a c -> f b d
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap a -> c
f b -> d
g
invmap2Profunctor :: Profunctor f
=> (a -> c) -> (c -> a)
-> (b -> d) -> (d -> b)
-> f a b -> f c d
invmap2Profunctor :: forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor a -> c
_ c -> a
f' b -> d
g d -> b
_ = (c -> a) -> (b -> d) -> f a b -> f c d
forall a b c d. (a -> b) -> (c -> d) -> f b c -> f a d
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap c -> a
f' b -> d
g
instance Invariant2 (->) where invmap2 :: forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> (a -> b) -> c -> d
invmap2 = (a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> (a -> b) -> c -> d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 Either where invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Either a b -> Either c d
invmap2 = (a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Either a b -> Either c d
forall (f :: * -> * -> *) a c b d.
Bifunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Bifunctor
instance Invariant2 (,) where invmap2 :: forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> (a, b) -> (c, d)
invmap2 a -> c
f c -> a
_ b -> d
g d -> b
_ ~(a
x, b
y) = (a -> c
f a
x, b -> d
g b
y)
instance Invariant2 ((,,) a) where invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> (a, a, b) -> (a, c, d)
invmap2 a -> c
f c -> a
_ b -> d
g d -> b
_ ~(a
a, a
x, b
y) = (a
a, a -> c
f a
x, b -> d
g b
y)
instance Invariant2 ((,,,) a b) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> (a, b, a, b) -> (a, b, c, d)
invmap2 a -> c
f c -> a
_ b -> d
g d -> b
_ ~(a
a, b
b, a
x, b
y) = (a
a, b
b, a -> c
f a
x, b -> d
g b
y)
instance Invariant2 ((,,,,) a b c) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> (a, b, c, a, b)
-> (a, b, c, c, d)
invmap2 a -> c
f c -> a
_ b -> d
g d -> b
_ ~(a
a, b
b, c
c, a
x, b
y) = (a
a, b
b, c
c, a -> c
f a
x, b -> d
g b
y)
instance Invariant2 Const where invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Const a b -> Const c d
invmap2 = (a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Const a b -> Const c d
forall (f :: * -> * -> *) a c b d.
Bifunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Bifunctor
instance Arrow arr => Invariant2 (App.WrappedArrow arr) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> WrappedArrow arr a b
-> WrappedArrow arr c d
invmap2 a -> c
_ c -> a
f' b -> d
g d -> b
_ (App.WrapArrow arr a b
x) = arr c d -> WrappedArrow arr c d
forall (a :: * -> * -> *) b c. a b c -> WrappedArrow a b c
App.WrapArrow (arr c d -> WrappedArrow arr c d)
-> arr c d -> WrappedArrow arr c d
forall a b. (a -> b) -> a -> b
$ (b -> d) -> arr b d
forall b c. (b -> c) -> arr b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr b -> d
g arr b d -> arr c b -> arr c d
forall b c a. arr b c -> arr a b -> arr a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
Cat.. arr a b
x arr a b -> arr c a -> arr c b
forall b c a. arr b c -> arr a b -> arr a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
Cat.. (c -> a) -> arr c a
forall b c. (b -> c) -> arr b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr c -> a
f'
instance Invariant m => Invariant2 (Kleisli m) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Kleisli m a b
-> Kleisli m c d
invmap2 a -> c
_ c -> a
f' b -> d
g d -> b
g' (Kleisli a -> m b
m) = (c -> m d) -> Kleisli m c d
forall (m :: * -> *) a b. (a -> m b) -> Kleisli m a b
Kleisli ((c -> m d) -> Kleisli m c d) -> (c -> m d) -> Kleisli m c d
forall a b. (a -> b) -> a -> b
$ (b -> d) -> (d -> b) -> m b -> m d
forall a b. (a -> b) -> (b -> a) -> m a -> m b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> d
g d -> b
g' (m b -> m d) -> (c -> m b) -> c -> m d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m b
m (a -> m b) -> (c -> a) -> c -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> a
f'
instance Invariant2 Arg where
invmap2 :: forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> Arg a b -> Arg c d
invmap2 = (a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> Arg a b -> Arg c d
forall (f :: * -> * -> *) a c b d.
Bifunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Bifunctor
instance (Invariant2 p, Invariant f, Invariant g) => Invariant2 (Biff p f g) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Biff p f g a b
-> Biff p f g c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' =
p (f c) (g d) -> Biff p f g c d
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 (p (f c) (g d) -> Biff p f g c d)
-> (Biff p f g a b -> p (f c) (g d))
-> Biff p f g a b
-> Biff p f g c d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (f a -> f c)
-> (f c -> f a)
-> (g b -> g d)
-> (g d -> g b)
-> p (f a) (g b)
-> p (f c) (g d)
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 ((a -> c) -> (c -> a) -> f a -> f c
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> c
f c -> a
f') ((c -> a) -> (a -> c) -> f c -> f a
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap c -> a
f' a -> c
f) ((b -> d) -> (d -> b) -> g b -> g d
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> d
g d -> b
g') ((d -> b) -> (b -> d) -> g d -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap d -> b
g' b -> d
g) (p (f a) (g b) -> p (f c) (g d))
-> (Biff p f g a b -> p (f a) (g b))
-> Biff p f g a b
-> p (f c) (g d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Biff p f g a b -> p (f a) (g b)
forall {k1} {k2} {k3} {k4} (p :: k1 -> k2 -> *) (f :: k3 -> k1)
(g :: k4 -> k2) (a :: k3) (b :: k4).
Biff p f g a b -> p (f a) (g b)
runBiff
instance Invariant f => Invariant2 (Clown f) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Clown f a b -> Clown f c d
invmap2 a -> c
f c -> a
f' b -> d
_ d -> b
_ = f c -> Clown f c d
forall {k} {k1} (f :: k -> *) (a :: k) (b :: k1).
f a -> Clown f a b
Clown (f c -> Clown f c d)
-> (Clown f a b -> f c) -> Clown f a b -> Clown f c d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> c) -> (c -> a) -> f a -> f c
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> c
f c -> a
f' (f a -> f c) -> (Clown f a b -> f a) -> Clown f a b -> f c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Clown f a b -> f a
forall {k1} {k2} (f :: k1 -> *) (a :: k1) (b :: k2).
Clown f a b -> f a
runClown
instance Invariant2 p => Invariant2 (Flip p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Flip p a b -> Flip p c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' = p d c -> Flip p c d
forall {k} {k1} (p :: k -> k1 -> *) (a :: k1) (b :: k).
p b a -> Flip p a b
Flip (p d c -> Flip p c d)
-> (Flip p a b -> p d c) -> Flip p a b -> Flip p c d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> d) -> (d -> b) -> (a -> c) -> (c -> a) -> p b a -> p d c
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 b -> d
g d -> b
g' a -> c
f c -> a
f' (p b a -> p d c) -> (Flip p a b -> p b a) -> Flip p a b -> p d c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Flip p a b -> p b a
forall {k1} {k2} (p :: k1 -> k2 -> *) (a :: k2) (b :: k1).
Flip p a b -> p b a
runFlip
instance Invariant g => Invariant2 (Joker g) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Joker g a b -> Joker g c d
invmap2 a -> c
_ c -> a
_ b -> d
g d -> b
g' = g d -> Joker g c d
forall {k} {k1} (g :: k -> *) (a :: k1) (b :: k).
g b -> Joker g a b
Joker (g d -> Joker g c d)
-> (Joker g a b -> g d) -> Joker g a b -> Joker g c d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> d) -> (d -> b) -> g b -> g d
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> d
g d -> b
g' (g b -> g d) -> (Joker g a b -> g b) -> Joker g a b -> g d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Joker g a b -> g b
forall {k1} {k2} (g :: k1 -> *) (a :: k2) (b :: k1).
Joker g a b -> g b
runJoker
instance (Invariant2 f, Invariant2 g) => Invariant2 (Bifunctor.Product f g) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Product f g a b
-> Product f g c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' (Bifunctor.Pair f a b
x g a b
y) =
f c d -> g c d -> Product f g c d
forall {k} {k1} (f :: k -> k1 -> *) (g :: k -> k1 -> *) (a :: k)
(b :: k1).
f a b -> g a b -> Product f g a b
Bifunctor.Pair ((a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' f a b
x) ((a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> g a b -> g c d
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> g a b -> g c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' g a b
y)
instance (Invariant2 p, Invariant2 q) => Invariant2 (Bifunctor.Sum p q) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Sum p q a b -> Sum p q c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' (Bifunctor.L2 p a b
l) = p c d -> Sum p q c d
forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
p a b -> Sum p q a b
Bifunctor.L2 ((a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' p a b
l)
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' (Bifunctor.R2 q a b
r) = q c d -> Sum p q c d
forall {k} {k1} (p :: k -> k1 -> *) (q :: k -> k1 -> *) (a :: k)
(b :: k1).
q a b -> Sum p q a b
Bifunctor.R2 ((a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> q a b -> q c d
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> q a b -> q c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' q a b
r)
instance (Invariant f, Invariant2 p) => Invariant2 (Tannen f p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Tannen f p a b
-> Tannen f p c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' =
f (p c d) -> Tannen f p c d
forall {k} {k1} {k2} (f :: k -> *) (p :: k1 -> k2 -> k) (a :: k1)
(b :: k2).
f (p a b) -> Tannen f p a b
Tannen (f (p c d) -> Tannen f p c d)
-> (Tannen f p a b -> f (p c d))
-> Tannen f p a b
-> Tannen f p c d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (p a b -> p c d) -> (p c d -> p a b) -> f (p a b) -> f (p c d)
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g') ((c -> a) -> (a -> c) -> (d -> b) -> (b -> d) -> p c d -> p a b
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 c -> a
f' a -> c
f d -> b
g' b -> d
g) (f (p a b) -> f (p c d))
-> (Tannen f p a b -> f (p a b)) -> Tannen f p a b -> f (p c d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tannen f p a b -> f (p a b)
forall {k1} {k2} {k3} (f :: k1 -> *) (p :: k2 -> k3 -> k1)
(a :: k2) (b :: k3).
Tannen f p a b -> f (p a b)
runTannen
instance Bifunctor p => Invariant2 (WrappedBifunctor p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> WrappedBifunctor p a b
-> WrappedBifunctor p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> WrappedBifunctor p a b
-> WrappedBifunctor p c d
forall (f :: * -> * -> *) a c b d.
Bifunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Bifunctor
instance Invariant w => Invariant2 (Cokleisli w) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Cokleisli w a b
-> Cokleisli w c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
_ (Cokleisli w a -> b
w) = (w c -> d) -> Cokleisli w c d
forall {k} (w :: k -> *) (a :: k) b. (w a -> b) -> Cokleisli w a b
Cokleisli ((w c -> d) -> Cokleisli w c d) -> (w c -> d) -> Cokleisli w c d
forall a b. (a -> b) -> a -> b
$ b -> d
g (b -> d) -> (w c -> b) -> w c -> d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. w a -> b
w (w a -> b) -> (w c -> w a) -> w c -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (c -> a) -> (a -> c) -> w c -> w a
forall a b. (a -> b) -> (b -> a) -> w a -> w b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap c -> a
f' a -> c
f
instance Invariant2 Op where
invmap2 :: forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> Op a b -> Op c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' (Op b -> a
x) = (d -> c) -> Op c d
forall a b. (b -> a) -> Op a b
Op ((d -> c) -> Op c d) -> (d -> c) -> Op c d
forall a b. (a -> b) -> a -> b
$ (b -> d) -> (d -> b) -> (a -> c) -> (c -> a) -> (b -> a) -> d -> c
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> (a -> b) -> c -> d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 b -> d
g d -> b
g' a -> c
f c -> a
f' b -> a
x
instance Invariant f => Invariant2 (Star f) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Star f a b -> Star f c d
invmap2 a -> c
_ c -> a
ba b -> d
cd d -> b
dc (Star a -> f b
afc) = (c -> f d) -> Star f c d
forall {k} (f :: k -> *) d (c :: k). (d -> f c) -> Star f d c
Star ((c -> f d) -> Star f c d) -> (c -> f d) -> Star f c d
forall a b. (a -> b) -> a -> b
$ (b -> d) -> (d -> b) -> f b -> f d
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> d
cd d -> b
dc (f b -> f d) -> (c -> f b) -> c -> f d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f b
afc (a -> f b) -> (c -> a) -> c -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> a
ba
instance Invariant f => Invariant2 (Costar f) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Costar f a b -> Costar f c d
invmap2 a -> c
ab c -> a
ba b -> d
cd d -> b
_ (Costar f a -> b
fbc) = (f c -> d) -> Costar f c d
forall {k} (f :: k -> *) (d :: k) c. (f d -> c) -> Costar f d c
Costar ((f c -> d) -> Costar f c d) -> (f c -> d) -> Costar f c d
forall a b. (a -> b) -> a -> b
$ b -> d
cd (b -> d) -> (f c -> b) -> f c -> d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> b
fbc (f a -> b) -> (f c -> f a) -> f c -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (c -> a) -> (a -> c) -> f c -> f a
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap c -> a
ba a -> c
ab
instance Arrow arr => Invariant2 (Pro.WrappedArrow arr) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> WrappedArrow arr a b
-> WrappedArrow arr c d
invmap2 a -> c
_ c -> a
f' b -> d
g d -> b
_ (Pro.WrapArrow arr a b
x) = arr c d -> WrappedArrow arr c d
forall {k} {k1} (p :: k -> k1 -> *) (a :: k) (b :: k1).
p a b -> WrappedArrow p a b
Pro.WrapArrow (arr c d -> WrappedArrow arr c d)
-> arr c d -> WrappedArrow arr c d
forall a b. (a -> b) -> a -> b
$ (b -> d) -> arr b d
forall b c. (b -> c) -> arr b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr b -> d
g arr b d -> arr c b -> arr c d
forall b c a. arr b c -> arr a b -> arr a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
Cat.. arr a b
x arr a b -> arr c a -> arr c b
forall b c a. arr b c -> arr a b -> arr a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
Cat.. (c -> a) -> arr c a
forall b c. (b -> c) -> arr b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr c -> a
f'
instance Invariant2 (Forget r) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Forget r a b -> Forget r c d
invmap2 = (a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Forget r a b -> Forget r c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance (Invariant f, Invariant2 p) => Invariant2 (Cayley f p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Cayley f p a b
-> Cayley f p c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' =
f (p c d) -> Cayley f p c d
forall {k} {k1} {k2} (f :: k -> *) (p :: k1 -> k2 -> k) (a :: k1)
(b :: k2).
f (p a b) -> Cayley f p a b
Cayley (f (p c d) -> Cayley f p c d)
-> (Cayley f p a b -> f (p c d))
-> Cayley f p a b
-> Cayley f p c d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (p a b -> p c d) -> (p c d -> p a b) -> f (p a b) -> f (p c d)
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g') ((c -> a) -> (a -> c) -> (d -> b) -> (b -> d) -> p c d -> p a b
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 c -> a
f' a -> c
f d -> b
g' b -> d
g) (f (p a b) -> f (p c d))
-> (Cayley f p a b -> f (p a b)) -> Cayley f p a b -> f (p c d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cayley f p a b -> f (p a b)
forall {k1} {k2} {k3} (f :: k1 -> *) (p :: k2 -> k3 -> k1)
(a :: k2) (b :: k3).
Cayley f p a b -> f (p a b)
runCayley
instance Invariant2 p => Invariant2 (Closure p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Closure p a b
-> Closure p c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' (Closure forall x. p (x -> a) (x -> b)
p) = (forall x. p (x -> c) (x -> d)) -> Closure p c d
forall (p :: * -> * -> *) a b.
(forall x. p (x -> a) (x -> b)) -> Closure p a b
Closure ((forall x. p (x -> c) (x -> d)) -> Closure p c d)
-> (forall x. p (x -> c) (x -> d)) -> Closure p c d
forall a b. (a -> b) -> a -> b
$ ((x -> a) -> x -> c)
-> ((x -> c) -> x -> a)
-> ((x -> b) -> x -> d)
-> ((x -> d) -> x -> b)
-> p (x -> a) (x -> b)
-> p (x -> c) (x -> d)
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 (a -> c
f (a -> c) -> (x -> a) -> x -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (c -> a
f' (c -> a) -> (x -> c) -> x -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (b -> d
g (b -> d) -> (x -> b) -> x -> d
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (d -> b
g' (d -> b) -> (x -> d) -> x -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) p (x -> a) (x -> b)
forall x. p (x -> a) (x -> b)
p
instance Invariant2 (Environment p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Environment p a b
-> Environment p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Environment p a b
-> Environment p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 p => Invariant2 (Codensity p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Codensity p a b
-> Codensity p c d
invmap2 a -> c
ac c -> a
ca b -> d
bd d -> b
db (Codensity forall x. p x a -> p x b
f) =
(forall x. p x c -> p x d) -> Codensity p c d
forall {k} {k1} (p :: k -> k1 -> *) (a :: k1) (b :: k1).
(forall (x :: k). p x a -> p x b) -> Codensity p a b
Codensity ((x -> x) -> (x -> x) -> (b -> d) -> (d -> b) -> p x b -> p x d
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id b -> d
bd d -> b
db (p x b -> p x d) -> (p x c -> p x b) -> p x c -> p x d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p x a -> p x b
forall x. p x a -> p x b
f (p x a -> p x b) -> (p x c -> p x a) -> p x c -> p x b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (x -> x) -> (x -> x) -> (c -> a) -> (a -> c) -> p x c -> p x a
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id c -> a
ca a -> c
ac)
instance (Invariant2 p, Invariant2 q) => Invariant2 (Procompose p q) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Procompose p q a b
-> Procompose p q c d
invmap2 a -> c
l c -> a
l' b -> d
r d -> b
r' (Procompose p x b
f q a x
g) =
p x d -> q c x -> Procompose p q c d
forall {k} {k1} {k2} (p :: k -> k1 -> *) (x :: k) (c :: k1)
(q :: k2 -> k -> *) (d :: k2).
p x c -> q d x -> Procompose p q d c
Procompose ((x -> x) -> (x -> x) -> (b -> d) -> (d -> b) -> p x b -> p x d
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id b -> d
r d -> b
r' p x b
f) ((a -> c) -> (c -> a) -> (x -> x) -> (x -> x) -> q a x -> q c x
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> q a b -> q c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> c
l c -> a
l' x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id q a x
g)
instance (Invariant2 p, Invariant2 q) => Invariant2 (Rift p q) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Rift p q a b -> Rift p q c d
invmap2 a -> c
ac c -> a
ca b -> d
bd d -> b
db (Rift forall x. p b x -> q a x
f) = (forall x. p d x -> q c x) -> Rift p q c d
forall {k} {k1} {k2} (p :: k -> k1 -> *) (q :: k2 -> k1 -> *)
(a :: k2) (b :: k).
(forall (x :: k1). p b x -> q a x) -> Rift p q a b
Rift ((a -> c) -> (c -> a) -> (x -> x) -> (x -> x) -> q a x -> q c x
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> q a b -> q c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> c
ac c -> a
ca x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id (q a x -> q c x) -> (p d x -> q a x) -> p d x -> q c x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p b x -> q a x
forall x. p b x -> q a x
f (p b x -> q a x) -> (p d x -> p b x) -> p d x -> q a x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (d -> b) -> (b -> d) -> (x -> x) -> (x -> x) -> p d x -> p b x
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 d -> b
db b -> d
bd x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id)
instance (Invariant2 p, Invariant2 q) => Invariant2 (Ran p q) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Ran p q a b -> Ran p q c d
invmap2 a -> c
ac c -> a
ca b -> d
bd d -> b
db (Ran forall x. p x a -> q x b
f) = (forall x. p x c -> q x d) -> Ran p q c d
forall {k} {k1} {k2} (p :: k -> k1 -> *) (q :: k -> k2 -> *)
(a :: k1) (b :: k2).
(forall (x :: k). p x a -> q x b) -> Ran p q a b
Ran ((x -> x) -> (x -> x) -> (b -> d) -> (d -> b) -> q x b -> q x d
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> q a b -> q c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id b -> d
bd d -> b
db (q x b -> q x d) -> (p x c -> q x b) -> p x c -> q x d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p x a -> q x b
forall x. p x a -> q x b
f (p x a -> q x b) -> (p x c -> p x a) -> p x c -> q x b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (x -> x) -> (x -> x) -> (c -> a) -> (a -> c) -> p x c -> p x a
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 x -> x
forall a. a -> a
id x -> x
forall a. a -> a
id c -> a
ca a -> c
ac)
instance Invariant2 p => Invariant2 (Tambara p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Tambara p a b
-> Tambara p c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' (Tambara forall c. p (a, c) (b, c)
p) =
(forall c. p (c, c) (d, c)) -> Tambara p c d
forall (p :: * -> * -> *) a b.
(forall c. p (a, c) (b, c)) -> Tambara p a b
Tambara ((forall c. p (c, c) (d, c)) -> Tambara p c d)
-> (forall c. p (c, c) (d, c)) -> Tambara p c d
forall a b. (a -> b) -> a -> b
$ ((a, c) -> (c, c))
-> ((c, c) -> (a, c))
-> ((b, c) -> (d, c))
-> ((d, c) -> (b, c))
-> p (a, c) (b, c)
-> p (c, c) (d, c)
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 ((a -> c) -> (a, c) -> (c, c)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> c
f) ((c -> a) -> (c, c) -> (a, c)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first c -> a
f') ((b -> d) -> (b, c) -> (d, c)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first b -> d
g) ((d -> b) -> (d, c) -> (b, c)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first d -> b
g') p (a, c) (b, c)
forall c. p (a, c) (b, c)
p
instance Invariant2 (PastroSum p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> PastroSum p a b
-> PastroSum p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> PastroSum p a b
-> PastroSum p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 p => Invariant2 (CofreeMapping p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> CofreeMapping p a b
-> CofreeMapping p c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' (CofreeMapping forall (f :: * -> *). Functor f => p (f a) (f b)
p) =
(forall (f :: * -> *). Functor f => p (f c) (f d))
-> CofreeMapping p c d
forall (p :: * -> * -> *) a b.
(forall (f :: * -> *). Functor f => p (f a) (f b))
-> CofreeMapping p a b
CofreeMapping ((f a -> f c)
-> (f c -> f a)
-> (f b -> f d)
-> (f d -> f b)
-> p (f a) (f b)
-> p (f c) (f d)
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 ((a -> c) -> f a -> f c
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> c
f) ((c -> a) -> f c -> f a
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> a
f') ((b -> d) -> f b -> f d
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> d
g) ((d -> b) -> f d -> f b
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap d -> b
g') p (f a) (f b)
forall (f :: * -> *). Functor f => p (f a) (f b)
p)
instance Invariant2 (FreeMapping p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> FreeMapping p a b
-> FreeMapping p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> FreeMapping p a b
-> FreeMapping p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 p => Invariant2 (CofreeTraversing p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> CofreeTraversing p a b
-> CofreeTraversing p c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' (CofreeTraversing forall (f :: * -> *). Traversable f => p (f a) (f b)
p) =
(forall (f :: * -> *). Traversable f => p (f c) (f d))
-> CofreeTraversing p c d
forall (p :: * -> * -> *) a b.
(forall (f :: * -> *). Traversable f => p (f a) (f b))
-> CofreeTraversing p a b
CofreeTraversing ((f a -> f c)
-> (f c -> f a)
-> (f b -> f d)
-> (f d -> f b)
-> p (f a) (f b)
-> p (f c) (f d)
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 ((a -> c) -> f a -> f c
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> c
f) ((c -> a) -> f c -> f a
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> a
f') ((b -> d) -> f b -> f d
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> d
g) ((d -> b) -> f d -> f b
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap d -> b
g') p (f a) (f b)
forall (f :: * -> *). Traversable f => p (f a) (f b)
p)
instance Invariant2 (FreeTraversing p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> FreeTraversing p a b
-> FreeTraversing p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> FreeTraversing p a b
-> FreeTraversing p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 (Pastro p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Pastro p a b -> Pastro p c d
invmap2 = (a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Pastro p a b -> Pastro p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 (Cotambara p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Cotambara p a b
-> Cotambara p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Cotambara p a b
-> Cotambara p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 (Copastro p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Copastro p a b
-> Copastro p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Copastro p a b
-> Copastro p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 (CopastroSum p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> CopastroSum p a b
-> CopastroSum p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> CopastroSum p a b
-> CopastroSum p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 (CotambaraSum p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> CotambaraSum p a b
-> CotambaraSum p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> CotambaraSum p a b
-> CotambaraSum p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 p => Invariant2 (TambaraSum p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> TambaraSum p a b
-> TambaraSum p c d
invmap2 a -> c
f c -> a
f' b -> d
g d -> b
g' (TambaraSum forall c. p (Either a c) (Either b c)
p) =
(forall c. p (Either c c) (Either d c)) -> TambaraSum p c d
forall (p :: * -> * -> *) a b.
(forall c. p (Either a c) (Either b c)) -> TambaraSum p a b
TambaraSum ((Either a c -> Either c c)
-> (Either c c -> Either a c)
-> (Either b c -> Either d c)
-> (Either d c -> Either b c)
-> p (Either a c) (Either b c)
-> p (Either c c) (Either d c)
forall a c b d.
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> p a b -> p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 ((a -> c) -> Either a c -> Either c c
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> c
f) ((c -> a) -> Either c c -> Either a c
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first c -> a
f') ((b -> d) -> Either b c -> Either d c
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first b -> d
g) ((d -> b) -> Either d c -> Either b c
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first d -> b
g') p (Either a c) (Either b c)
forall c. p (Either a c) (Either b c)
p)
instance Invariant2 (Yoneda p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Yoneda p a b -> Yoneda p c d
invmap2 = (a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Yoneda p a b -> Yoneda p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 (Coyoneda p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Coyoneda p a b
-> Coyoneda p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> Coyoneda p a b
-> Coyoneda p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Invariant2 Tagged where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Tagged a b -> Tagged c d
invmap2 = (a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Tagged a b -> Tagged c d
forall (f :: * -> * -> *) a c b d.
Bifunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Bifunctor
instance Invariant2 Constant where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> Constant a b -> Constant c d
invmap2 a -> c
f c -> a
_ b -> d
_ d -> b
_ (Constant a
x) = c -> Constant c d
forall {k} a (b :: k). a -> Constant a b
Constant (a -> c
f a
x)
newtype WrappedProfunctor p a b = WrapProfunctor { forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor :: p a b }
deriving (WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
(WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool)
-> (WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool)
-> Eq (WrappedProfunctor p a b)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Eq (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
$c== :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Eq (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
== :: WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
$c/= :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Eq (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
/= :: WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
Eq, Eq (WrappedProfunctor p a b)
Eq (WrappedProfunctor p a b) =>
(WrappedProfunctor p a b -> WrappedProfunctor p a b -> Ordering)
-> (WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool)
-> (WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool)
-> (WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool)
-> (WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool)
-> (WrappedProfunctor p a b
-> WrappedProfunctor p a b -> WrappedProfunctor p a b)
-> (WrappedProfunctor p a b
-> WrappedProfunctor p a b -> WrappedProfunctor p a b)
-> Ord (WrappedProfunctor p a b)
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Ordering
WrappedProfunctor p a b
-> WrappedProfunctor p a b -> WrappedProfunctor p a b
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
Eq (WrappedProfunctor p a b)
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Ordering
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b
-> WrappedProfunctor p a b -> WrappedProfunctor p a b
$ccompare :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Ordering
compare :: WrappedProfunctor p a b -> WrappedProfunctor p a b -> Ordering
$c< :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
< :: WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
$c<= :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
<= :: WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
$c> :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
> :: WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
$c>= :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
>= :: WrappedProfunctor p a b -> WrappedProfunctor p a b -> Bool
$cmax :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b
-> WrappedProfunctor p a b -> WrappedProfunctor p a b
max :: WrappedProfunctor p a b
-> WrappedProfunctor p a b -> WrappedProfunctor p a b
$cmin :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Ord (p a b) =>
WrappedProfunctor p a b
-> WrappedProfunctor p a b -> WrappedProfunctor p a b
min :: WrappedProfunctor p a b
-> WrappedProfunctor p a b -> WrappedProfunctor p a b
Ord, ReadPrec [WrappedProfunctor p a b]
ReadPrec (WrappedProfunctor p a b)
Int -> ReadS (WrappedProfunctor p a b)
ReadS [WrappedProfunctor p a b]
(Int -> ReadS (WrappedProfunctor p a b))
-> ReadS [WrappedProfunctor p a b]
-> ReadPrec (WrappedProfunctor p a b)
-> ReadPrec [WrappedProfunctor p a b]
-> Read (WrappedProfunctor p a b)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Read (p a b) =>
ReadPrec [WrappedProfunctor p a b]
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Read (p a b) =>
ReadPrec (WrappedProfunctor p a b)
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Read (p a b) =>
Int -> ReadS (WrappedProfunctor p a b)
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Read (p a b) =>
ReadS [WrappedProfunctor p a b]
$creadsPrec :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Read (p a b) =>
Int -> ReadS (WrappedProfunctor p a b)
readsPrec :: Int -> ReadS (WrappedProfunctor p a b)
$creadList :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Read (p a b) =>
ReadS [WrappedProfunctor p a b]
readList :: ReadS [WrappedProfunctor p a b]
$creadPrec :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Read (p a b) =>
ReadPrec (WrappedProfunctor p a b)
readPrec :: ReadPrec (WrappedProfunctor p a b)
$creadListPrec :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Read (p a b) =>
ReadPrec [WrappedProfunctor p a b]
readListPrec :: ReadPrec [WrappedProfunctor p a b]
Read, Int -> WrappedProfunctor p a b -> ShowS
[WrappedProfunctor p a b] -> ShowS
WrappedProfunctor p a b -> String
(Int -> WrappedProfunctor p a b -> ShowS)
-> (WrappedProfunctor p a b -> String)
-> ([WrappedProfunctor p a b] -> ShowS)
-> Show (WrappedProfunctor p a b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Show (p a b) =>
Int -> WrappedProfunctor p a b -> ShowS
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Show (p a b) =>
[WrappedProfunctor p a b] -> ShowS
forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Show (p a b) =>
WrappedProfunctor p a b -> String
$cshowsPrec :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Show (p a b) =>
Int -> WrappedProfunctor p a b -> ShowS
showsPrec :: Int -> WrappedProfunctor p a b -> ShowS
$cshow :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Show (p a b) =>
WrappedProfunctor p a b -> String
show :: WrappedProfunctor p a b -> String
$cshowList :: forall k k (p :: k -> k -> *) (a :: k) (b :: k).
Show (p a b) =>
[WrappedProfunctor p a b] -> ShowS
showList :: [WrappedProfunctor p a b] -> ShowS
Show)
instance Profunctor p => Invariant2 (WrappedProfunctor p) where
invmap2 :: forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> WrappedProfunctor p a b
-> WrappedProfunctor p c d
invmap2 = (a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> WrappedProfunctor p a b
-> WrappedProfunctor p c d
forall (f :: * -> * -> *) a c b d.
Profunctor f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2Profunctor
instance Profunctor p => Invariant (WrappedProfunctor p a) where
invmap :: forall a b.
(a -> b)
-> (b -> a) -> WrappedProfunctor p a a -> WrappedProfunctor p a b
invmap = (a -> a)
-> (a -> a)
-> (a -> b)
-> (b -> a)
-> WrappedProfunctor p a a
-> WrappedProfunctor p a b
forall a c b d.
(a -> c)
-> (c -> a)
-> (b -> d)
-> (d -> b)
-> WrappedProfunctor p a b
-> WrappedProfunctor p c d
forall (f :: * -> * -> *) a c b d.
Invariant2 f =>
(a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
invmap2 a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id
instance Profunctor p => Profunctor (WrappedProfunctor p) where
dimap :: forall a b c d.
(a -> b)
-> (c -> d) -> WrappedProfunctor p b c -> WrappedProfunctor p a d
dimap a -> b
f c -> d
g = p a d -> WrappedProfunctor p a d
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p a d -> WrappedProfunctor p a d)
-> (WrappedProfunctor p b c -> p a d)
-> WrappedProfunctor p b c
-> WrappedProfunctor p a d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> (c -> d) -> p b c -> p a d
forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
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 a d)
-> (WrappedProfunctor p b c -> p b c)
-> WrappedProfunctor p b c
-> p a d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p b c -> p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
lmap :: forall a b c.
(a -> b) -> WrappedProfunctor p b c -> WrappedProfunctor p a c
lmap a -> b
f = p a c -> WrappedProfunctor p a c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p a c -> WrappedProfunctor p a c)
-> (WrappedProfunctor p b c -> p a c)
-> WrappedProfunctor p b c
-> WrappedProfunctor p a c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> p b c -> p a c
forall a b c. (a -> b) -> p b c -> p a c
forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap a -> b
f (p b c -> p a c)
-> (WrappedProfunctor p b c -> p b c)
-> WrappedProfunctor p b c
-> p a c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p b c -> p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
rmap :: forall b c a.
(b -> c) -> WrappedProfunctor p a b -> WrappedProfunctor p a c
rmap b -> c
g = p a c -> WrappedProfunctor p a c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p a c -> WrappedProfunctor p a c)
-> (WrappedProfunctor p a b -> p a c)
-> WrappedProfunctor p a b
-> WrappedProfunctor p a c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> c) -> p a b -> p a c
forall b c a. (b -> c) -> p a b -> p a c
forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap b -> c
g (p a b -> p a c)
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> p a c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
WrapProfunctor p b c
x .# :: forall a b c (q :: * -> * -> *).
Coercible b a =>
WrappedProfunctor p b c -> q a b -> WrappedProfunctor p a c
.# q a b
f = p a c -> WrappedProfunctor p a c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p b c
x p b c -> q a b -> p a c
forall a b c (q :: * -> * -> *).
Coercible b a =>
p b c -> q a b -> p a c
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
g #. :: forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> WrappedProfunctor p a b -> WrappedProfunctor p a c
#. WrapProfunctor p a b
x = p a c -> WrappedProfunctor p a c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (q b c
g q b c -> p a b -> p a c
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> p a b -> p a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. p a b
x)
instance Cat.Category p => Cat.Category (WrappedProfunctor p) where
id :: forall (a :: k). WrappedProfunctor p a a
id = p a a -> WrappedProfunctor p a a
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor p a a
forall (a :: k). p a a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
Cat.id
WrapProfunctor p b c
p1 . :: forall (b :: k) (c :: k) (a :: k).
WrappedProfunctor p b c
-> WrappedProfunctor p a b -> WrappedProfunctor p a c
. WrapProfunctor p a b
p2 = p a c -> WrappedProfunctor p a c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p b c
p1 p b c -> p a b -> p a c
forall (b :: k) (c :: k) (a :: k). p b c -> p a b -> p a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
Cat.. p a b
p2)
instance Arrow p => Arrow (WrappedProfunctor p) where
arr :: forall b c. (b -> c) -> WrappedProfunctor p b c
arr = p b c -> WrappedProfunctor p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p b c -> WrappedProfunctor p b c)
-> ((b -> c) -> p b c) -> (b -> c) -> WrappedProfunctor p b c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> c) -> p b c
forall b c. (b -> c) -> p b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr
first :: forall b c d.
WrappedProfunctor p b c -> WrappedProfunctor p (b, d) (c, d)
first = p (b, d) (c, d) -> WrappedProfunctor p (b, d) (c, d)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (b, d) (c, d) -> WrappedProfunctor p (b, d) (c, d))
-> (WrappedProfunctor p b c -> p (b, d) (c, d))
-> WrappedProfunctor p b c
-> WrappedProfunctor p (b, d) (c, d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p b c -> p (b, d) (c, d)
forall b c d. p b c -> p (b, d) (c, d)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
Arr.first (p b c -> p (b, d) (c, d))
-> (WrappedProfunctor p b c -> p b c)
-> WrappedProfunctor p b c
-> p (b, d) (c, d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p b c -> p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
second :: forall b c d.
WrappedProfunctor p b c -> WrappedProfunctor p (d, b) (d, c)
second = p (d, b) (d, c) -> WrappedProfunctor p (d, b) (d, c)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (d, b) (d, c) -> WrappedProfunctor p (d, b) (d, c))
-> (WrappedProfunctor p b c -> p (d, b) (d, c))
-> WrappedProfunctor p b c
-> WrappedProfunctor p (d, b) (d, c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p b c -> p (d, b) (d, c)
forall b c d. p b c -> p (d, b) (d, c)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
Arr.second (p b c -> p (d, b) (d, c))
-> (WrappedProfunctor p b c -> p b c)
-> WrappedProfunctor p b c
-> p (d, b) (d, c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p b c -> p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
WrapProfunctor p b c
p1 *** :: forall b c b' c'.
WrappedProfunctor p b c
-> WrappedProfunctor p b' c' -> WrappedProfunctor p (b, b') (c, c')
*** WrapProfunctor p b' c'
p2 = p (b, b') (c, c') -> WrappedProfunctor p (b, b') (c, c')
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p b c
p1 p b c -> p b' c' -> p (b, b') (c, c')
forall b c b' c'. p b c -> p b' c' -> p (b, b') (c, c')
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** p b' c'
p2)
WrapProfunctor p b c
p1 &&& :: forall b c c'.
WrappedProfunctor p b c
-> WrappedProfunctor p b c' -> WrappedProfunctor p b (c, c')
&&& WrapProfunctor p b c'
p2 = p b (c, c') -> WrappedProfunctor p b (c, c')
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p b c
p1 p b c -> p b c' -> p b (c, c')
forall b c c'. p b c -> p b c' -> p b (c, c')
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& p b c'
p2)
instance ArrowZero p => ArrowZero (WrappedProfunctor p) where
zeroArrow :: forall b c. WrappedProfunctor p b c
zeroArrow = p b c -> WrappedProfunctor p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor p b c
forall b c. p b c
forall (a :: * -> * -> *) b c. ArrowZero a => a b c
zeroArrow
instance ArrowPlus p => ArrowPlus (WrappedProfunctor p) where
WrapProfunctor p b c
p1 <+> :: forall b c.
WrappedProfunctor p b c
-> WrappedProfunctor p b c -> WrappedProfunctor p b c
<+> WrapProfunctor p b c
p2 = p b c -> WrappedProfunctor p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p b c
p1 p b c -> p b c -> p b c
forall b c. p b c -> p b c -> p b c
forall (a :: * -> * -> *) b c.
ArrowPlus a =>
a b c -> a b c -> a b c
<+> p b c
p2)
instance ArrowChoice p => ArrowChoice (WrappedProfunctor p) where
left :: forall b c d.
WrappedProfunctor p b c
-> WrappedProfunctor p (Either b d) (Either c d)
left = p (Either b d) (Either c d)
-> WrappedProfunctor p (Either b d) (Either c d)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (Either b d) (Either c d)
-> WrappedProfunctor p (Either b d) (Either c d))
-> (WrappedProfunctor p b c -> p (Either b d) (Either c d))
-> WrappedProfunctor p b c
-> WrappedProfunctor p (Either b d) (Either c d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p b c -> p (Either b d) (Either c d)
forall b c d. p b c -> p (Either b d) (Either c d)
forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either b d) (Either c d)
left (p b c -> p (Either b d) (Either c d))
-> (WrappedProfunctor p b c -> p b c)
-> WrappedProfunctor p b c
-> p (Either b d) (Either c d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p b c -> p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
right :: forall b c d.
WrappedProfunctor p b c
-> WrappedProfunctor p (Either d b) (Either d c)
right = p (Either d b) (Either d c)
-> WrappedProfunctor p (Either d b) (Either d c)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (Either d b) (Either d c)
-> WrappedProfunctor p (Either d b) (Either d c))
-> (WrappedProfunctor p b c -> p (Either d b) (Either d c))
-> WrappedProfunctor p b c
-> WrappedProfunctor p (Either d b) (Either d c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p b c -> p (Either d b) (Either d c)
forall b c d. p b c -> p (Either d b) (Either d c)
forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either d b) (Either d c)
right (p b c -> p (Either d b) (Either d c))
-> (WrappedProfunctor p b c -> p b c)
-> WrappedProfunctor p b c
-> p (Either d b) (Either d c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p b c -> p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
WrapProfunctor p b c
p1 +++ :: forall b c b' c'.
WrappedProfunctor p b c
-> WrappedProfunctor p b' c'
-> WrappedProfunctor p (Either b b') (Either c c')
+++ WrapProfunctor p b' c'
p2 = p (Either b b') (Either c c')
-> WrappedProfunctor p (Either b b') (Either c c')
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p b c
p1 p b c -> p b' c' -> p (Either b b') (Either c c')
forall b c b' c'. p b c -> p b' c' -> p (Either b b') (Either c c')
forall (a :: * -> * -> *) b c b' c'.
ArrowChoice a =>
a b c -> a b' c' -> a (Either b b') (Either c c')
+++ p b' c'
p2)
WrapProfunctor p b d
p1 ||| :: forall b d c.
WrappedProfunctor p b d
-> WrappedProfunctor p c d -> WrappedProfunctor p (Either b c) d
||| WrapProfunctor p c d
p2 = p (Either b c) d -> WrappedProfunctor p (Either b c) d
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p b d
p1 p b d -> p c d -> p (Either b c) d
forall b d c. p b d -> p c d -> p (Either b c) d
forall (a :: * -> * -> *) b d c.
ArrowChoice a =>
a b d -> a c d -> a (Either b c) d
||| p c d
p2)
instance ArrowLoop p => ArrowLoop (WrappedProfunctor p) where
loop :: forall b d c.
WrappedProfunctor p (b, d) (c, d) -> WrappedProfunctor p b c
loop = p b c -> WrappedProfunctor p b c
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p b c -> WrappedProfunctor p b c)
-> (WrappedProfunctor p (b, d) (c, d) -> p b c)
-> WrappedProfunctor p (b, d) (c, d)
-> WrappedProfunctor p b c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p (b, d) (c, d) -> p b c
forall b d c. p (b, d) (c, d) -> p b c
forall (a :: * -> * -> *) b d c.
ArrowLoop a =>
a (b, d) (c, d) -> a b c
loop (p (b, d) (c, d) -> p b c)
-> (WrappedProfunctor p (b, d) (c, d) -> p (b, d) (c, d))
-> WrappedProfunctor p (b, d) (c, d)
-> p b c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p (b, d) (c, d) -> p (b, d) (c, d)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance Strong p => Strong (WrappedProfunctor p) where
first' :: forall a b c.
WrappedProfunctor p a b -> WrappedProfunctor p (a, c) (b, c)
first' = p (a, c) (b, c) -> WrappedProfunctor p (a, c) (b, c)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (a, c) (b, c) -> WrappedProfunctor p (a, c) (b, c))
-> (WrappedProfunctor p a b -> p (a, c) (b, c))
-> WrappedProfunctor p a b
-> WrappedProfunctor p (a, c) (b, c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p a b -> p (a, c) (b, c)
forall a b c. p a b -> p (a, c) (b, c)
forall (p :: * -> * -> *) a b c.
Strong p =>
p a b -> p (a, c) (b, c)
first' (p a b -> p (a, c) (b, c))
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> p (a, c) (b, c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
second' :: forall a b c.
WrappedProfunctor p a b -> WrappedProfunctor p (c, a) (c, b)
second' = p (c, a) (c, b) -> WrappedProfunctor p (c, a) (c, b)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (c, a) (c, b) -> WrappedProfunctor p (c, a) (c, b))
-> (WrappedProfunctor p a b -> p (c, a) (c, b))
-> WrappedProfunctor p a b
-> WrappedProfunctor p (c, a) (c, b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p a b -> p (c, a) (c, b)
forall a b c. p a b -> p (c, a) (c, b)
forall (p :: * -> * -> *) a b c.
Strong p =>
p a b -> p (c, a) (c, b)
second' (p a b -> p (c, a) (c, b))
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> p (c, a) (c, b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance Choice p => Choice (WrappedProfunctor p) where
left' :: forall a b c.
WrappedProfunctor p a b
-> WrappedProfunctor p (Either a c) (Either b c)
left' = p (Either a c) (Either b c)
-> WrappedProfunctor p (Either a c) (Either b c)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (Either a c) (Either b c)
-> WrappedProfunctor p (Either a c) (Either b c))
-> (WrappedProfunctor p a b -> p (Either a c) (Either b c))
-> WrappedProfunctor p a b
-> WrappedProfunctor p (Either a c) (Either b c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p a b -> p (Either a c) (Either b c)
forall a b c. p a b -> p (Either a c) (Either b c)
forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either a c) (Either b c)
left' (p a b -> p (Either a c) (Either b c))
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> p (Either a c) (Either b c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
right' :: forall a b c.
WrappedProfunctor p a b
-> WrappedProfunctor p (Either c a) (Either c b)
right' = p (Either c a) (Either c b)
-> WrappedProfunctor p (Either c a) (Either c b)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (Either c a) (Either c b)
-> WrappedProfunctor p (Either c a) (Either c b))
-> (WrappedProfunctor p a b -> p (Either c a) (Either c b))
-> WrappedProfunctor p a b
-> WrappedProfunctor p (Either c a) (Either c b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p a b -> p (Either c a) (Either c b)
forall a b c. p a b -> p (Either c a) (Either c b)
forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' (p a b -> p (Either c a) (Either c b))
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> p (Either c a) (Either c b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance Costrong p => Costrong (WrappedProfunctor p) where
unfirst :: forall a d b.
WrappedProfunctor p (a, d) (b, d) -> WrappedProfunctor p a b
unfirst = p a b -> WrappedProfunctor p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p a b -> WrappedProfunctor p a b)
-> (WrappedProfunctor p (a, d) (b, d) -> p a b)
-> WrappedProfunctor p (a, d) (b, d)
-> WrappedProfunctor p a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p (a, d) (b, d) -> p a b
forall a d b. p (a, d) (b, d) -> p a b
forall (p :: * -> * -> *) a d b.
Costrong p =>
p (a, d) (b, d) -> p a b
unfirst (p (a, d) (b, d) -> p a b)
-> (WrappedProfunctor p (a, d) (b, d) -> p (a, d) (b, d))
-> WrappedProfunctor p (a, d) (b, d)
-> p a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p (a, d) (b, d) -> p (a, d) (b, d)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
unsecond :: forall d a b.
WrappedProfunctor p (d, a) (d, b) -> WrappedProfunctor p a b
unsecond = p a b -> WrappedProfunctor p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p a b -> WrappedProfunctor p a b)
-> (WrappedProfunctor p (d, a) (d, b) -> p a b)
-> WrappedProfunctor p (d, a) (d, b)
-> WrappedProfunctor p a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p (d, a) (d, b) -> p a b
forall d a b. p (d, a) (d, b) -> p a b
forall (p :: * -> * -> *) d a b.
Costrong p =>
p (d, a) (d, b) -> p a b
unsecond (p (d, a) (d, b) -> p a b)
-> (WrappedProfunctor p (d, a) (d, b) -> p (d, a) (d, b))
-> WrappedProfunctor p (d, a) (d, b)
-> p a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p (d, a) (d, b) -> p (d, a) (d, b)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance Cochoice p => Cochoice (WrappedProfunctor p) where
unleft :: forall a d b.
WrappedProfunctor p (Either a d) (Either b d)
-> WrappedProfunctor p a b
unleft = p a b -> WrappedProfunctor p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p a b -> WrappedProfunctor p a b)
-> (WrappedProfunctor p (Either a d) (Either b d) -> p a b)
-> WrappedProfunctor p (Either a d) (Either b d)
-> WrappedProfunctor p a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p (Either a d) (Either b d) -> p a b
forall a d b. p (Either a d) (Either b d) -> p a b
forall (p :: * -> * -> *) a d b.
Cochoice p =>
p (Either a d) (Either b d) -> p a b
unleft (p (Either a d) (Either b d) -> p a b)
-> (WrappedProfunctor p (Either a d) (Either b d)
-> p (Either a d) (Either b d))
-> WrappedProfunctor p (Either a d) (Either b d)
-> p a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p (Either a d) (Either b d)
-> p (Either a d) (Either b d)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
unright :: forall d a b.
WrappedProfunctor p (Either d a) (Either d b)
-> WrappedProfunctor p a b
unright = p a b -> WrappedProfunctor p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p a b -> WrappedProfunctor p a b)
-> (WrappedProfunctor p (Either d a) (Either d b) -> p a b)
-> WrappedProfunctor p (Either d a) (Either d b)
-> WrappedProfunctor p a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p (Either d a) (Either d b) -> p a b
forall d a b. p (Either d a) (Either d b) -> p a b
forall (p :: * -> * -> *) d a b.
Cochoice p =>
p (Either d a) (Either d b) -> p a b
unright (p (Either d a) (Either d b) -> p a b)
-> (WrappedProfunctor p (Either d a) (Either d b)
-> p (Either d a) (Either d b))
-> WrappedProfunctor p (Either d a) (Either d b)
-> p a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p (Either d a) (Either d b)
-> p (Either d a) (Either d b)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance Closed p => Closed (WrappedProfunctor p) where
closed :: forall a b x.
WrappedProfunctor p a b -> WrappedProfunctor p (x -> a) (x -> b)
closed = p (x -> a) (x -> b) -> WrappedProfunctor p (x -> a) (x -> b)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (x -> a) (x -> b) -> WrappedProfunctor p (x -> a) (x -> b))
-> (WrappedProfunctor p a b -> p (x -> a) (x -> b))
-> WrappedProfunctor p a b
-> WrappedProfunctor p (x -> a) (x -> b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p a b -> p (x -> a) (x -> b)
forall a b x. p a b -> p (x -> a) (x -> b)
forall (p :: * -> * -> *) a b x.
Closed p =>
p a b -> p (x -> a) (x -> b)
closed (p a b -> p (x -> a) (x -> b))
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> p (x -> a) (x -> b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance Traversing p => Traversing (WrappedProfunctor p) where
traverse' :: forall (f :: * -> *) a b.
Traversable f =>
WrappedProfunctor p a b -> WrappedProfunctor p (f a) (f b)
traverse' = p (f a) (f b) -> WrappedProfunctor p (f a) (f b)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (f a) (f b) -> WrappedProfunctor p (f a) (f b))
-> (WrappedProfunctor p a b -> p (f a) (f b))
-> WrappedProfunctor p a b
-> WrappedProfunctor p (f a) (f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p a b -> p (f a) (f b)
forall (f :: * -> *) a b. Traversable f => p a b -> p (f a) (f b)
forall (p :: * -> * -> *) (f :: * -> *) a b.
(Traversing p, Traversable f) =>
p a b -> p (f a) (f b)
traverse' (p a b -> p (f a) (f b))
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> p (f a) (f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
wander :: forall a b s t.
(forall (f :: * -> *). Applicative f => (a -> f b) -> s -> f t)
-> WrappedProfunctor p a b -> WrappedProfunctor p s t
wander forall (f :: * -> *). Applicative f => (a -> f b) -> s -> f t
f = p s t -> WrappedProfunctor p s t
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p s t -> WrappedProfunctor p s t)
-> (WrappedProfunctor p a b -> p s t)
-> WrappedProfunctor p a b
-> WrappedProfunctor p s t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall (f :: * -> *). Applicative f => (a -> f b) -> s -> f t)
-> p a b -> p s t
forall a b s t.
(forall (f :: * -> *). Applicative f => (a -> f b) -> s -> f t)
-> p a b -> p s t
forall (p :: * -> * -> *) a b s t.
Traversing p =>
(forall (f :: * -> *). Applicative f => (a -> f b) -> s -> f t)
-> p a b -> p s t
wander (a -> f b) -> s -> f t
forall (f :: * -> *). Applicative f => (a -> f b) -> s -> f t
f (p a b -> p s t)
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> p s t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance Mapping p => Mapping (WrappedProfunctor p) where
map' :: forall (f :: * -> *) a b.
Functor f =>
WrappedProfunctor p a b -> WrappedProfunctor p (f a) (f b)
map' = p (f a) (f b) -> WrappedProfunctor p (f a) (f b)
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (p (f a) (f b) -> WrappedProfunctor p (f a) (f b))
-> (WrappedProfunctor p a b -> p (f a) (f b))
-> WrappedProfunctor p a b
-> WrappedProfunctor p (f a) (f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p a b -> p (f a) (f b)
forall (f :: * -> *) a b. Functor f => p a b -> p (f a) (f b)
forall (p :: * -> * -> *) (f :: * -> *) a b.
(Mapping p, Functor f) =>
p a b -> p (f a) (f b)
map' (p a b -> p (f a) (f b))
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> p (f a) (f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance ProfunctorFunctor WrappedProfunctor where
promap :: forall (p :: * -> * -> *) (q :: * -> * -> *).
Profunctor p =>
(p :-> q) -> WrappedProfunctor p :-> WrappedProfunctor q
promap p :-> q
f = q a b -> WrappedProfunctor q a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor (q a b -> WrappedProfunctor q a b)
-> (WrappedProfunctor p a b -> q a b)
-> WrappedProfunctor p a b
-> WrappedProfunctor q a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p a b -> q a b
p :-> q
f (p a b -> q a b)
-> (WrappedProfunctor p a b -> p a b)
-> WrappedProfunctor p a b
-> q a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance ProfunctorMonad WrappedProfunctor where
proreturn :: forall (p :: * -> * -> *).
Profunctor p =>
p :-> WrappedProfunctor p
proreturn = p a b -> WrappedProfunctor p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor
projoin :: forall (p :: * -> * -> *).
Profunctor p =>
WrappedProfunctor (WrappedProfunctor p) :-> WrappedProfunctor p
projoin = WrappedProfunctor (WrappedProfunctor p) a b
-> WrappedProfunctor p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
instance ProfunctorComonad WrappedProfunctor where
proextract :: forall (p :: * -> * -> *).
Profunctor p =>
WrappedProfunctor p :-> p
proextract = WrappedProfunctor p a b -> p a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
WrappedProfunctor p a b -> p a b
unwrapProfunctor
produplicate :: forall (p :: * -> * -> *).
Profunctor p =>
WrappedProfunctor p :-> WrappedProfunctor (WrappedProfunctor p)
produplicate = WrappedProfunctor p a b
-> WrappedProfunctor (WrappedProfunctor p) a b
forall {k} {k} (p :: k -> k -> *) (a :: k) (b :: k).
p a b -> WrappedProfunctor p a b
WrapProfunctor
#if GHC_GENERICS_OK
instance Invariant V1 where
invmap :: forall a b. (a -> b) -> (b -> a) -> V1 a -> V1 b
invmap a -> b
_ b -> a
_ V1 a
x = V1 a
x V1 a -> V1 b -> V1 b
forall a b. a -> b -> b
`seq` String -> V1 b
forall a. HasCallStack => String -> a
error String
"Invariant V1"
instance Invariant U1 where invmap :: forall a b. (a -> b) -> (b -> a) -> U1 a -> U1 b
invmap a -> b
_ b -> a
_ U1 a
_ = U1 b
forall k (p :: k). U1 p
U1
instance (Invariant l, Invariant r) => Invariant ((:+:) l r) where
invmap :: forall a b. (a -> b) -> (b -> a) -> (:+:) l r a -> (:+:) l r b
invmap a -> b
f b -> a
g (L1 l a
l) = l b -> (:+:) l r b
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (l b -> (:+:) l r b) -> l b -> (:+:) l r b
forall a b. (a -> b) -> a -> b
$ (a -> b) -> (b -> a) -> l a -> l b
forall a b. (a -> b) -> (b -> a) -> l a -> l b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g l a
l
invmap a -> b
f b -> a
g (R1 r a
r) = r b -> (:+:) l r b
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (r b -> (:+:) l r b) -> r b -> (:+:) l r b
forall a b. (a -> b) -> a -> b
$ (a -> b) -> (b -> a) -> r a -> r b
forall a b. (a -> b) -> (b -> a) -> r a -> r b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g r a
r
instance (Invariant l, Invariant r) => Invariant ((:*:) l r) where
invmap :: forall a b. (a -> b) -> (b -> a) -> (:*:) l r a -> (:*:) l r b
invmap a -> b
f b -> a
g ~(l a
l :*: r a
r) = (a -> b) -> (b -> a) -> l a -> l b
forall a b. (a -> b) -> (b -> a) -> l a -> l b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g l a
l l b -> r b -> (:*:) l r b
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
:*: (a -> b) -> (b -> a) -> r a -> r b
forall a b. (a -> b) -> (b -> a) -> r a -> r b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g r a
r
instance Invariant (K1 i c) where invmap :: forall a b. (a -> b) -> (b -> a) -> K1 i c a -> K1 i c b
invmap a -> b
_ b -> a
_ (K1 c
c) = c -> K1 i c b
forall k i c (p :: k). c -> K1 i c p
K1 c
c
instance Invariant2 (K1 i) where invmap2 :: forall a c b d.
(a -> c)
-> (c -> a) -> (b -> d) -> (d -> b) -> K1 i a b -> K1 i c d
invmap2 a -> c
f c -> a
_ b -> d
_ d -> b
_ (K1 a
c) = c -> K1 i c d
forall k i c (p :: k). c -> K1 i c p
K1 (c -> K1 i c d) -> c -> K1 i c d
forall a b. (a -> b) -> a -> b
$ a -> c
f a
c
instance Invariant f => Invariant (M1 i t f) where invmap :: forall a b. (a -> b) -> (b -> a) -> M1 i t f a -> M1 i t f b
invmap a -> b
f b -> a
g (M1 f a
fp) = f b -> M1 i t f b
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (f b -> M1 i t f b) -> f b -> M1 i t f b
forall a b. (a -> b) -> a -> b
$ (a -> b) -> (b -> a) -> f a -> f b
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g f a
fp
instance Invariant Par1 where invmap :: forall a b. (a -> b) -> (b -> a) -> Par1 a -> Par1 b
invmap a -> b
f b -> a
_ (Par1 a
c) = b -> Par1 b
forall p. p -> Par1 p
Par1 (b -> Par1 b) -> b -> Par1 b
forall a b. (a -> b) -> a -> b
$ a -> b
f a
c
instance Invariant f => Invariant (Rec1 f) where invmap :: forall a b. (a -> b) -> (b -> a) -> Rec1 f a -> Rec1 f b
invmap a -> b
f b -> a
g (Rec1 f a
fp) = f b -> Rec1 f b
forall k (f :: k -> *) (p :: k). f p -> Rec1 f p
Rec1 (f b -> Rec1 f b) -> f b -> Rec1 f b
forall a b. (a -> b) -> a -> b
$ (a -> b) -> (b -> a) -> f a -> f b
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g f a
fp
instance (Invariant f, Invariant g) => Invariant ((:.:) f g) where
invmap :: forall a b. (a -> b) -> (b -> a) -> (:.:) f g a -> (:.:) f g b
invmap a -> b
f b -> a
g (Comp1 f (g a)
fgp) = f (g b) -> (:.:) f g b
forall k2 k1 (f :: k2 -> *) (g :: k1 -> k2) (p :: k1).
f (g p) -> (:.:) f g p
Comp1 (f (g b) -> (:.:) f g b) -> f (g b) -> (:.:) f g b
forall a b. (a -> b) -> a -> b
$ (g a -> g b) -> (g b -> g a) -> f (g a) -> f (g b)
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap ((a -> b) -> (b -> a) -> g a -> g b
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) ((b -> a) -> (a -> b) -> g b -> g a
forall a b. (a -> b) -> (b -> a) -> g a -> g b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap b -> a
g a -> b
f) f (g a)
fgp
# if __GLASGOW_HASKELL__ >= 800
instance Invariant UAddr where
invmap :: forall a b. (a -> b) -> (b -> a) -> UAddr a -> UAddr b
invmap a -> b
_ b -> a
_ (UAddr Addr#
a) = Addr# -> URec (Ptr ()) b
forall k (p :: k). Addr# -> URec (Ptr ()) p
UAddr Addr#
a
instance Invariant UChar where
invmap :: forall a b. (a -> b) -> (b -> a) -> UChar a -> UChar b
invmap a -> b
_ b -> a
_ (UChar Char#
c) = Char# -> URec Char b
forall k (p :: k). Char# -> URec Char p
UChar Char#
c
instance Invariant UDouble where
invmap :: forall a b. (a -> b) -> (b -> a) -> UDouble a -> UDouble b
invmap a -> b
_ b -> a
_ (UDouble Double#
d) = Double# -> URec Double b
forall k (p :: k). Double# -> URec Double p
UDouble Double#
d
instance Invariant UFloat where
invmap :: forall a b. (a -> b) -> (b -> a) -> UFloat a -> UFloat b
invmap a -> b
_ b -> a
_ (UFloat Float#
f) = Float# -> URec Float b
forall k (p :: k). Float# -> URec Float p
UFloat Float#
f
instance Invariant UInt where
invmap :: forall a b. (a -> b) -> (b -> a) -> UInt a -> UInt b
invmap a -> b
_ b -> a
_ (UInt Int#
i) = Int# -> URec Int b
forall k (p :: k). Int# -> URec Int p
UInt Int#
i
instance Invariant UWord where
invmap :: forall a b. (a -> b) -> (b -> a) -> UWord a -> UWord b
invmap a -> b
_ b -> a
_ (UWord Word#
w) = Word# -> URec Word b
forall k (p :: k). Word# -> URec Word p
UWord Word#
w
# endif
genericInvmap :: (Generic1 f, Invariant (Rep1 f)) => (a -> b) -> (b -> a) -> f a -> f b
genericInvmap :: forall (f :: * -> *) a b.
(Generic1 f, Invariant (Rep1 f)) =>
(a -> b) -> (b -> a) -> f a -> f b
genericInvmap a -> b
f b -> a
g = Rep1 f b -> f b
forall a. Rep1 f a -> f a
forall k (f :: k -> *) (a :: k). Generic1 f => Rep1 f a -> f a
to1 (Rep1 f b -> f b) -> (f a -> Rep1 f b) -> f a -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> (b -> a) -> Rep1 f a -> Rep1 f b
forall a b. (a -> b) -> (b -> a) -> Rep1 f a -> Rep1 f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g (Rep1 f a -> Rep1 f b) -> (f a -> Rep1 f a) -> f a -> Rep1 f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> Rep1 f a
forall a. f a -> Rep1 f a
forall k (f :: k -> *) (a :: k). Generic1 f => f a -> Rep1 f a
from1
#endif
newtype InvariantProfunctor p a = InvariantProfunctor (p a a)
instance Profunctor p => Invariant (InvariantProfunctor p) where
invmap :: forall a b.
(a -> b)
-> (b -> a) -> InvariantProfunctor p a -> InvariantProfunctor p b
invmap a -> b
fn1 b -> a
fn2 (InvariantProfunctor p a a
f) = p b b -> InvariantProfunctor p b
forall {k} (p :: k -> k -> *) (a :: k).
p a a -> InvariantProfunctor p a
InvariantProfunctor ((a -> b) -> (b -> a) -> p a a -> p b b
forall (p :: * -> * -> *) a b.
Profunctor p =>
(a -> b) -> (b -> a) -> p a a -> p b b
invmapProfunctor a -> b
fn1 b -> a
fn2 p a a
f)
newtype InvariantArrow c a = InvariantArrow (c a a)
instance Arrow c => Invariant (InvariantArrow c) where
invmap :: forall a b.
(a -> b) -> (b -> a) -> InvariantArrow c a -> InvariantArrow c b
invmap a -> b
fn1 b -> a
fn2 (InvariantArrow c a a
arrow) = c b b -> InvariantArrow c b
forall {k} (c :: k -> k -> *) (a :: k). c a a -> InvariantArrow c a
InvariantArrow ((a -> b) -> (b -> a) -> c a a -> c b b
forall (arr :: * -> * -> *) a b.
Arrow arr =>
(a -> b) -> (b -> a) -> arr a a -> arr b b
invmapArrow a -> b
fn1 b -> a
fn2 c a a
arrow)