{-# LANGUAGE CPP #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
------------------------------------------------------------------------------
-- |
-- Module      :  Control.Lens.Reified
-- Copyright   :  (C) 2012-16 Edward Kmett
-- License     :  BSD-style (see the file LICENSE)
-- Maintainer  :  Edward Kmett <ekmett@gmail.com>
-- Stability   :  provisional
-- Portability :  Rank2Types
--
------------------------------------------------------------------------------
module Control.Lens.Reified where

import Control.Applicative
import Control.Arrow
import qualified Control.Category as Cat
import Control.Comonad
import Control.Lens.Fold
import Control.Lens.Getter
import Control.Lens.Internal.Indexed
import Control.Lens.Traversal (ignored)
import Control.Lens.Type
import Control.Monad
import Control.Monad.Reader.Class
import Data.Distributive
import Data.Foldable
import Data.Functor.Compose
import Data.Functor.Contravariant
import Data.Functor.Bind
import Data.Functor.Extend
import Data.Functor.Identity
import Data.Functor.Plus
import Data.Profunctor.Closed
import Data.Profunctor
import Data.Profunctor.Rep
import Data.Profunctor.Sieve
#if !(MIN_VERSION_base(4,11,0))
import Data.Semigroup
#endif

-- $setup
-- >>> import Control.Lens
-- >>> import Control.Applicative

------------------------------------------------------------------------------
-- Lens
------------------------------------------------------------------------------

-- | Reify a t'Lens' so it can be stored safely in a container.
newtype ReifiedLens s t a b = Lens { forall s t a b. ReifiedLens s t a b -> Lens s t a b
runLens :: Lens s t a b }

-- | @
-- type 'ReifiedLens'' = 'Simple' 'ReifiedLens'
-- @
type ReifiedLens' s a = ReifiedLens s s a a

------------------------------------------------------------------------------
-- IndexedLens
------------------------------------------------------------------------------

-- | Reify an t'IndexedLens' so it can be stored safely in a container.
newtype ReifiedIndexedLens i s t a b = IndexedLens { forall i s t a b.
ReifiedIndexedLens i s t a b -> IndexedLens i s t a b
runIndexedLens :: IndexedLens i s t a b }

-- | @
-- type 'ReifiedIndexedLens'' i = 'Simple' ('ReifiedIndexedLens' i)
-- @
type ReifiedIndexedLens' i s a = ReifiedIndexedLens i s s a a

------------------------------------------------------------------------------
-- IndexedTraversal
------------------------------------------------------------------------------

-- | Reify an t'IndexedTraversal' so it can be stored safely in a container.
newtype ReifiedIndexedTraversal i s t a b = IndexedTraversal { forall i s t a b.
ReifiedIndexedTraversal i s t a b -> IndexedTraversal i s t a b
runIndexedTraversal :: IndexedTraversal i s t a b }

-- | @
-- type 'ReifiedIndexedTraversal'' i = 'Simple' ('ReifiedIndexedTraversal' i)
-- @
type ReifiedIndexedTraversal' i s a = ReifiedIndexedTraversal i s s a a

------------------------------------------------------------------------------
-- Traversal
------------------------------------------------------------------------------

-- | A form of t'Traversal' that can be stored monomorphically in a container.
newtype ReifiedTraversal s t a b = Traversal { forall s t a b. ReifiedTraversal s t a b -> Traversal s t a b
runTraversal :: Traversal s t a b }

-- | @
-- type 'ReifiedTraversal'' = 'Simple' 'ReifiedTraversal'
-- @
type ReifiedTraversal' s a = ReifiedTraversal s s a a

------------------------------------------------------------------------------
-- Getter
------------------------------------------------------------------------------

-- | Reify a t'Getter' so it can be stored safely in a container.
--
-- This can also be useful when combining getters in novel ways, as
-- 'ReifiedGetter' is isomorphic to '(->)' and provides similar instances.
--
-- >>> ("hello","world","!!!")^.runGetter ((,) <$> Getter _2 <*> Getter (_1.to length))
-- ("world",5)
newtype ReifiedGetter s a = Getter { forall s a. ReifiedGetter s a -> Getter s a
runGetter :: Getter s a }

instance Distributive (ReifiedGetter s) where
  distribute :: forall (f :: * -> *) a.
Functor f =>
f (ReifiedGetter s a) -> ReifiedGetter s (f a)
distribute f (ReifiedGetter s a)
as = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
s -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Getter Getter s a
l) -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s a
l s
s) f (ReifiedGetter s a)
as

instance Functor (ReifiedGetter s) where
  fmap :: forall a b. (a -> b) -> ReifiedGetter s a -> ReifiedGetter s b
fmap a -> b
f ReifiedGetter s a
l = forall s a. Getter s a -> ReifiedGetter s a
Getter (forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter s a
lforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
f)
  {-# INLINE fmap #-}

instance Semigroup s => Extend (ReifiedGetter s) where
  duplicated :: forall a. ReifiedGetter s a -> ReifiedGetter s (ReifiedGetter s a)
duplicated (Getter Getter s a
l) = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
m -> forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
n -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s a
l (s
m forall a. Semigroup a => a -> a -> a
<> s
n)
  {-# INLINE duplicated #-}

instance Monoid s => Comonad (ReifiedGetter s) where
  extract :: forall a. ReifiedGetter s a -> a
extract (Getter Getter s a
l) = forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s a
l forall a. Monoid a => a
mempty
  {-# INLINE extract #-}
  duplicate :: forall a. ReifiedGetter s a -> ReifiedGetter s (ReifiedGetter s a)
duplicate (Getter Getter s a
l) = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
m -> forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
n -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s a
l (forall a. Monoid a => a -> a -> a
mappend s
m s
n)
  {-# INLINE duplicate #-}

instance Monoid s => ComonadApply (ReifiedGetter s) where
  Getter Getter s (a -> b)
mf <@> :: forall a b.
ReifiedGetter s (a -> b) -> ReifiedGetter s a -> ReifiedGetter s b
<@> Getter Getter s a
ma = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
s -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s (a -> b)
mf s
s (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s a
ma s
s)
  {-# INLINE (<@>) #-}
  ReifiedGetter s a
m <@ :: forall a b.
ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s a
<@ ReifiedGetter s b
_ = ReifiedGetter s a
m
  {-# INLINE (<@) #-}
  ReifiedGetter s a
_ @> :: forall a b.
ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s b
@> ReifiedGetter s b
m = ReifiedGetter s b
m
  {-# INLINE (@>) #-}

instance Apply (ReifiedGetter s) where
  Getter Getter s (a -> b)
mf <.> :: forall a b.
ReifiedGetter s (a -> b) -> ReifiedGetter s a -> ReifiedGetter s b
<.> Getter Getter s a
ma = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
s -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s (a -> b)
mf s
s (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s a
ma s
s)
  {-# INLINE (<.>) #-}
  ReifiedGetter s a
m <. :: forall a b.
ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s a
<. ReifiedGetter s b
_ = ReifiedGetter s a
m
  {-# INLINE (<.) #-}
  ReifiedGetter s a
_ .> :: forall a b.
ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s b
.> ReifiedGetter s b
m = ReifiedGetter s b
m
  {-# INLINE (.>) #-}

instance Applicative (ReifiedGetter s) where
  pure :: forall a. a -> ReifiedGetter s a
pure a
a = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
_ -> a
a
  {-# INLINE pure #-}
  Getter Getter s (a -> b)
mf <*> :: forall a b.
ReifiedGetter s (a -> b) -> ReifiedGetter s a -> ReifiedGetter s b
<*> Getter Getter s a
ma = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
s -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s (a -> b)
mf s
s (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s a
ma s
s)
  {-# INLINE (<*>) #-}
  ReifiedGetter s a
m <* :: forall a b.
ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s a
<* ReifiedGetter s b
_ = ReifiedGetter s a
m
  {-# INLINE (<*) #-}
  ReifiedGetter s a
_ *> :: forall a b.
ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s b
*> ReifiedGetter s b
m = ReifiedGetter s b
m
  {-# INLINE (*>) #-}

instance Bind (ReifiedGetter s) where
  Getter Getter s a
ma >>- :: forall a b.
ReifiedGetter s a -> (a -> ReifiedGetter s b) -> ReifiedGetter s b
>>- a -> ReifiedGetter s b
f = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
s -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view (forall s a. ReifiedGetter s a -> Getter s a
runGetter (a -> ReifiedGetter s b
f (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s a
ma s
s))) s
s
  {-# INLINE (>>-) #-}

instance Monad (ReifiedGetter s) where
  return :: forall a. a -> ReifiedGetter s a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
  {-# INLINE return #-}
  Getter Getter s a
ma >>= :: forall a b.
ReifiedGetter s a -> (a -> ReifiedGetter s b) -> ReifiedGetter s b
>>= a -> ReifiedGetter s b
f = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \s
s -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view (forall s a. ReifiedGetter s a -> Getter s a
runGetter (a -> ReifiedGetter s b
f (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter s a
ma s
s))) s
s
  {-# INLINE (>>=) #-}

instance MonadReader s (ReifiedGetter s) where
  ask :: ReifiedGetter s s
ask = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a. a -> a
id
  {-# INLINE ask #-}
  local :: forall a. (s -> s) -> ReifiedGetter s a -> ReifiedGetter s a
local s -> s
f ReifiedGetter s a
m = forall s a. Getter s a -> ReifiedGetter s a
Getter (forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to s -> s
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter s a
m)
  {-# INLINE local #-}

instance Profunctor ReifiedGetter where
  dimap :: forall a b c d.
(a -> b) -> (c -> d) -> ReifiedGetter b c -> ReifiedGetter a d
dimap a -> b
f c -> d
g ReifiedGetter b c
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
fforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter b c
lforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to c -> d
g
  {-# INLINE dimap #-}
  lmap :: forall a b c. (a -> b) -> ReifiedGetter b c -> ReifiedGetter a c
lmap a -> b
g ReifiedGetter b c
l    = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
gforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter b c
l
  {-# INLINE lmap #-}
  rmap :: forall b c a. (b -> c) -> ReifiedGetter a b -> ReifiedGetter a c
rmap b -> c
f ReifiedGetter a b
l    = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter a b
lforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to b -> c
f
  {-# INLINE rmap #-}

instance Closed ReifiedGetter where
  closed :: forall a b x. ReifiedGetter a b -> ReifiedGetter (x -> a) (x -> b)
closed ReifiedGetter a b
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \x -> a
f -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view (forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter a b
l) forall b c a. (b -> c) -> (a -> b) -> a -> c
. x -> a
f

instance Cosieve ReifiedGetter Identity where
  cosieve :: forall a b. ReifiedGetter a b -> Identity a -> b
cosieve (Getter Getter a b
l) = forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter a b
l forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Identity a -> a
runIdentity

instance Corepresentable ReifiedGetter where
  type Corep ReifiedGetter = Identity
  cotabulate :: forall d c. (Corep ReifiedGetter d -> c) -> ReifiedGetter d c
cotabulate Corep ReifiedGetter d -> c
f = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to (Corep ReifiedGetter d -> c
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Identity a
Identity)

instance Sieve ReifiedGetter Identity where
  sieve :: forall a b. ReifiedGetter a b -> a -> Identity b
sieve (Getter Getter a b
l) = forall a. a -> Identity a
Identity forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter a b
l

instance Representable ReifiedGetter where
  type Rep ReifiedGetter = Identity
  tabulate :: forall d c. (d -> Rep ReifiedGetter c) -> ReifiedGetter d c
tabulate d -> Rep ReifiedGetter c
f = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to (forall a. Identity a -> a
runIdentity forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> Rep ReifiedGetter c
f)

instance Costrong ReifiedGetter where
  unfirst :: forall a d b. ReifiedGetter (a, d) (b, d) -> ReifiedGetter a b
unfirst ReifiedGetter (a, d) (b, d)
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) a d b.
Costrong p =>
p (a, d) (b, d) -> p a b
unfirst forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view (forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter (a, d) (b, d)
l)

instance Conjoined ReifiedGetter

instance Strong ReifiedGetter where
  first' :: forall a b c. ReifiedGetter a b -> ReifiedGetter (a, c) (b, c)
first' ReifiedGetter a b
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ \(b, c) -> f (b, c)
f (a
s,c
c) ->
    forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter a b
l (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (forall a b c. (a -> b -> c) -> b -> a -> c
flip (,) c
c) forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom (b, c) -> f (b, c)
f) a
s
  {-# INLINE first' #-}
  second' :: forall a b c. ReifiedGetter a b -> ReifiedGetter (c, a) (c, b)
second' ReifiedGetter a b
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ \(c, b) -> f (c, b)
f (c
c,a
s) ->
    forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter a b
l (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap ((,) c
c) forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom (c, b) -> f (c, b)
f) a
s
  {-# INLINE second' #-}

instance Choice ReifiedGetter where
  left' :: forall a b c.
ReifiedGetter a b -> ReifiedGetter (Either a c) (Either b c)
left' ReifiedGetter a b
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either a c) (Either b c)
left' forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter a b
l
  {-# INLINE left' #-}
  right' :: forall a b c.
ReifiedGetter a b -> ReifiedGetter (Either c a) (Either c b)
right' ReifiedGetter a b
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter a b
l
  {-# INLINE right' #-}

instance Cat.Category ReifiedGetter where
  id :: forall s. ReifiedGetter s s
id = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a. a -> a
id
  ReifiedGetter b c
l . :: forall b c a.
ReifiedGetter b c -> ReifiedGetter a b -> ReifiedGetter a c
. ReifiedGetter a b
r = forall s a. Getter s a -> ReifiedGetter s a
Getter (forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter a b
rforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter b c
l)
  {-# INLINE (.) #-}

instance Arrow ReifiedGetter where
  arr :: forall s a. (s -> a) -> ReifiedGetter s a
arr b -> c
f = forall s a. Getter s a -> ReifiedGetter s a
Getter (forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to b -> c
f)
  {-# INLINE arr #-}
  first :: forall a b c. ReifiedGetter a b -> ReifiedGetter (a, c) (b, c)
first ReifiedGetter b c
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter b c
l
  {-# INLINE first #-}
  second :: forall a b c. ReifiedGetter a b -> ReifiedGetter (c, a) (c, b)
second ReifiedGetter b c
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter b c
l
  {-# INLINE second #-}
  Getter Getter b c
l *** :: forall b c b' c'.
ReifiedGetter b c
-> ReifiedGetter b' c' -> ReifiedGetter (b, b') (c, c')
*** Getter Getter b' c'
r = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter b c
l forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter b' c'
r
  {-# INLINE (***) #-}
  Getter Getter b c
l &&& :: forall b c c'.
ReifiedGetter b c -> ReifiedGetter b c' -> ReifiedGetter b (c, c')
&&& Getter Getter b c'
r = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter b c
l forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter b c'
r
  {-# INLINE (&&&) #-}

instance ArrowApply ReifiedGetter where
  app :: forall b c. ReifiedGetter (ReifiedGetter b c, b) c
app = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ \(Getter Getter b c
bc, b
b) -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter b c
bc b
b
  {-# INLINE app #-}

instance ArrowChoice ReifiedGetter where
  left :: forall a b c.
ReifiedGetter a b -> ReifiedGetter (Either a c) (Either b c)
left ReifiedGetter b c
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either b d) (Either c d)
left forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter b c
l
  {-# INLINE left #-}
  right :: forall a b c.
ReifiedGetter a b -> ReifiedGetter (Either c a) (Either c b)
right ReifiedGetter b c
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either d b) (Either d c)
right forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter b c
l
  {-# INLINE right #-}
  Getter Getter b c
l +++ :: forall b c b' c'.
ReifiedGetter b c
-> ReifiedGetter b' c' -> ReifiedGetter (Either b b') (Either c c')
+++ Getter Getter b' c'
r = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter b c
l forall (a :: * -> * -> *) b c b' c'.
ArrowChoice a =>
a b c -> a b' c' -> a (Either b b') (Either c c')
+++ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter b' c'
r
  {-# INLINE (+++) #-}
  Getter Getter b d
l ||| :: forall b d c.
ReifiedGetter b d
-> ReifiedGetter c d -> ReifiedGetter (Either b c) d
||| Getter Getter c d
r = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter b d
l forall (a :: * -> * -> *) b d c.
ArrowChoice a =>
a b d -> a c d -> a (Either b c) d
||| forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getter c d
r
  {-# INLINE (|||) #-}

instance ArrowLoop ReifiedGetter where
  loop :: forall a d b. ReifiedGetter (a, d) (b, d) -> ReifiedGetter a b
loop ReifiedGetter (b, d) (c, d)
l = forall s a. Getter s a -> ReifiedGetter s a
Getter forall a b. (a -> b) -> a -> b
$ forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) b d c.
ArrowLoop a =>
a (b, d) (c, d) -> a b c
loop forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedGetter s a -> Getter s a
runGetter ReifiedGetter (b, d) (c, d)
l
  {-# INLINE loop #-}

------------------------------------------------------------------------------
-- IndexedGetter
------------------------------------------------------------------------------

-- | Reify an t'IndexedGetter' so it can be stored safely in a container.
newtype ReifiedIndexedGetter i s a = IndexedGetter { forall i s a. ReifiedIndexedGetter i s a -> IndexedGetter i s a
runIndexedGetter :: IndexedGetter i s a }

instance Profunctor (ReifiedIndexedGetter i) where
  dimap :: forall a b c d.
(a -> b)
-> (c -> d)
-> ReifiedIndexedGetter i b c
-> ReifiedIndexedGetter i a d
dimap a -> b
f c -> d
g ReifiedIndexedGetter i b c
l = forall i s a. IndexedGetter i s a -> ReifiedIndexedGetter i s a
IndexedGetter (forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i s a. ReifiedIndexedGetter i s a -> IndexedGetter i s a
runIndexedGetter ReifiedIndexedGetter i b c
l forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to c -> d
g)
  {-# INLINE dimap #-}

instance Sieve (ReifiedIndexedGetter i) ((,) i) where
  sieve :: forall a b. ReifiedIndexedGetter i a b -> a -> (i, b)
sieve (IndexedGetter IndexedGetter i a b
l) = forall s (m :: * -> *) i a.
MonadReader s m =>
IndexedGetting i (i, a) s a -> m (i, a)
iview IndexedGetter i a b
l
  {-# INLINE sieve #-}

instance Representable (ReifiedIndexedGetter i) where
  type Rep (ReifiedIndexedGetter i) = (,) i
  tabulate :: forall d c.
(d -> Rep (ReifiedIndexedGetter i) c) -> ReifiedIndexedGetter i d c
tabulate d -> Rep (ReifiedIndexedGetter i) c
f = forall i s a. IndexedGetter i s a -> ReifiedIndexedGetter i s a
IndexedGetter forall a b. (a -> b) -> a -> b
$ forall i (p :: * -> * -> *) (f :: * -> *) s a.
(Indexable i p, Contravariant f) =>
(s -> (i, a)) -> Over' p f s a
ito d -> Rep (ReifiedIndexedGetter i) c
f
  {-# INLINE tabulate #-}

instance Strong (ReifiedIndexedGetter i) where
  first' :: forall a b c.
ReifiedIndexedGetter i a b -> ReifiedIndexedGetter i (a, c) (b, c)
first' ReifiedIndexedGetter i a b
l = forall i s a. IndexedGetter i s a -> ReifiedIndexedGetter i s a
IndexedGetter forall a b. (a -> b) -> a -> b
$ \p (b, c) (f (b, c))
f (a
s,c
c) ->
    forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall a b. (a -> b) -> a -> b
$ forall i s a. ReifiedIndexedGetter i s a -> IndexedGetter i s a
runIndexedGetter ReifiedIndexedGetter i a b
l (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (forall a b c. (a -> b -> c) -> b -> a -> c
flip (,) c
c) forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom p (b, c) (f (b, c))
f) a
s
  {-# INLINE first' #-}
  second' :: forall a b c.
ReifiedIndexedGetter i a b -> ReifiedIndexedGetter i (c, a) (c, b)
second' ReifiedIndexedGetter i a b
l = forall i s a. IndexedGetter i s a -> ReifiedIndexedGetter i s a
IndexedGetter forall a b. (a -> b) -> a -> b
$ \p (c, b) (f (c, b))
f (c
c,a
s) ->
    forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall a b. (a -> b) -> a -> b
$ forall i s a. ReifiedIndexedGetter i s a -> IndexedGetter i s a
runIndexedGetter ReifiedIndexedGetter i a b
l (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap ((,) c
c) forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom p (c, b) (f (c, b))
f) a
s
  {-# INLINE second' #-}

instance Functor (ReifiedIndexedGetter i s) where
  fmap :: forall a b.
(a -> b)
-> ReifiedIndexedGetter i s a -> ReifiedIndexedGetter i s b
fmap a -> b
f ReifiedIndexedGetter i s a
l = forall i s a. IndexedGetter i s a -> ReifiedIndexedGetter i s a
IndexedGetter (forall i s a. ReifiedIndexedGetter i s a -> IndexedGetter i s a
runIndexedGetter ReifiedIndexedGetter i s a
lforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
f)
  {-# INLINE fmap #-}

instance Semigroup i => Apply (ReifiedIndexedGetter i s) where
  IndexedGetter IndexedGetter i s (a -> b)
mf <.> :: forall a b.
ReifiedIndexedGetter i s (a -> b)
-> ReifiedIndexedGetter i s a -> ReifiedIndexedGetter i s b
<.> IndexedGetter IndexedGetter i s a
ma = forall i s a. IndexedGetter i s a -> ReifiedIndexedGetter i s a
IndexedGetter forall a b. (a -> b) -> a -> b
$ \p b (f b)
k s
s ->
    case forall s (m :: * -> *) i a.
MonadReader s m =>
IndexedGetting i (i, a) s a -> m (i, a)
iview IndexedGetter i s (a -> b)
mf s
s of
      (i
i, a -> b
f) -> case forall s (m :: * -> *) i a.
MonadReader s m =>
IndexedGetting i (i, a) s a -> m (i, a)
iview IndexedGetter i s a
ma s
s of
        (i
j, a
a) -> forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall a b. (a -> b) -> a -> b
$ forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p b (f b)
k (i
i forall a. Semigroup a => a -> a -> a
<> i
j) (a -> b
f a
a)
  {-# INLINE (<.>) #-}


------------------------------------------------------------------------------
-- Fold
------------------------------------------------------------------------------

-- | Reify a t'Fold' so it can be stored safely in a container.
--
-- This can also be useful for creatively combining folds as
-- @'ReifiedFold' s@ is isomorphic to @ReaderT s []@ and provides similar
-- instances.
--
-- >>> ("hello","world")^..runFold ((,) <$> Fold _2 <*> Fold both)
-- [("world","hello"),("world","world")]
newtype ReifiedFold s a = Fold { forall s a. ReifiedFold s a -> Fold s a
runFold :: Fold s a }

instance Profunctor ReifiedFold where
  dimap :: forall a b c d.
(a -> b) -> (c -> d) -> ReifiedFold b c -> ReifiedFold a d
dimap a -> b
f c -> d
g ReifiedFold b c
l = forall s a. Fold s a -> ReifiedFold s a
Fold (forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. ReifiedFold s a -> Fold s a
runFold ReifiedFold b c
l forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to c -> d
g)
  {-# INLINE dimap #-}
  rmap :: forall b c a. (b -> c) -> ReifiedFold a b -> ReifiedFold a c
rmap b -> c
g ReifiedFold a b
l = forall s a. Fold s a -> ReifiedFold s a
Fold (forall s a. ReifiedFold s a -> Fold s a
runFold ReifiedFold a b
l forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to b -> c
g)
  {-# INLINE rmap #-}
  lmap :: forall a b c. (a -> b) -> ReifiedFold b c -> ReifiedFold a c
lmap a -> b
f ReifiedFold b c
l = forall s a. Fold s a -> ReifiedFold s a
Fold (forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. ReifiedFold s a -> Fold s a
runFold ReifiedFold b c
l)
  {-# INLINE lmap #-}

instance Sieve ReifiedFold [] where
  sieve :: forall a b. ReifiedFold a b -> a -> [b]
sieve (Fold Fold a b
l) = forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold a b
l

instance Representable ReifiedFold where
  type Rep ReifiedFold = []
  tabulate :: forall d c. (d -> Rep ReifiedFold c) -> ReifiedFold d c
tabulate d -> Rep ReifiedFold c
f = forall s a. Fold s a -> ReifiedFold s a
Fold (forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding d -> Rep ReifiedFold c
f)

instance Strong ReifiedFold where
  first' :: forall a b c. ReifiedFold a b -> ReifiedFold (a, c) (b, c)
first' ReifiedFold a b
l = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ \(b, c) -> f (b, c)
f (a
s,c
c) ->
    forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedFold s a -> Fold s a
runFold ReifiedFold a b
l (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (forall a b c. (a -> b -> c) -> b -> a -> c
flip (,) c
c) forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom (b, c) -> f (b, c)
f) a
s
  {-# INLINE first' #-}
  second' :: forall a b c. ReifiedFold a b -> ReifiedFold (c, a) (c, b)
second' ReifiedFold a b
l = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ \(c, b) -> f (c, b)
f (c
c,a
s) ->
    forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall a b. (a -> b) -> a -> b
$ forall s a. ReifiedFold s a -> Fold s a
runFold ReifiedFold a b
l (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap ((,) c
c) forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom (c, b) -> f (c, b)
f) a
s
  {-# INLINE second' #-}

instance Choice ReifiedFold where
  left' :: forall a b c.
ReifiedFold a b -> ReifiedFold (Either a c) (Either b c)
left' (Fold Fold a b
l) = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \Either a c
esc -> case Either a c
esc of
    Left a
s -> forall a b. a -> Either a b
Left forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold a b
l a
s
    Right c
c -> [forall a b. b -> Either a b
Right c
c]
  {-# INLINE left' #-}
  right' :: forall a b c.
ReifiedFold a b -> ReifiedFold (Either c a) (Either c b)
right' (Fold Fold a b
l) = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \Either c a
ecs -> case Either c a
ecs of
    Left c
c -> [forall a b. a -> Either a b
Left c
c]
    Right a
s -> forall a b. b -> Either a b
Right forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold a b
l a
s
  {-# INLINE right' #-}

instance Cat.Category ReifiedFold where
  id :: forall a. ReifiedFold a a
id = forall s a. Fold s a -> ReifiedFold s a
Fold forall a. a -> a
id
  ReifiedFold b c
l . :: forall b c a. ReifiedFold b c -> ReifiedFold a b -> ReifiedFold a c
. ReifiedFold a b
r = forall s a. Fold s a -> ReifiedFold s a
Fold (forall s a. ReifiedFold s a -> Fold s a
runFold ReifiedFold a b
r forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. ReifiedFold s a -> Fold s a
runFold ReifiedFold b c
l)
  {-# INLINE (.) #-}

instance Arrow ReifiedFold where
  arr :: forall b c. (b -> c) -> ReifiedFold b c
arr b -> c
f = forall s a. Fold s a -> ReifiedFold s a
Fold (forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to b -> c
f)
  {-# INLINE arr #-}
  first :: forall a b c. ReifiedFold a b -> ReifiedFold (a, c) (b, c)
first = forall (p :: * -> * -> *) a b c.
Strong p =>
p a b -> p (a, c) (b, c)
first'
  {-# INLINE first #-}
  second :: forall a b c. ReifiedFold a b -> ReifiedFold (c, a) (c, b)
second = forall (p :: * -> * -> *) a b c.
Strong p =>
p a b -> p (c, a) (c, b)
second'
  {-# INLINE second #-}
  Fold Fold b c
l *** :: forall b c b' c'.
ReifiedFold b c -> ReifiedFold b' c' -> ReifiedFold (b, b') (c, c')
*** Fold Fold b' c'
r = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \(b
x,b'
y) -> (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold b c
l b
x forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold b' c'
r b'
y
  {-# INLINE (***) #-}
  Fold Fold b c
l &&& :: forall b c c'.
ReifiedFold b c -> ReifiedFold b c' -> ReifiedFold b (c, c')
&&& Fold Fold b c'
r = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \b
x -> (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold b c
l b
x forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold b c'
r b
x
  {-# INLINE (&&&) #-}

instance ArrowChoice ReifiedFold where
  left :: forall a b c.
ReifiedFold a b -> ReifiedFold (Either a c) (Either b c)
left = forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either a c) (Either b c)
left'
  {-# INLINE left #-}
  right :: forall a b c.
ReifiedFold a b -> ReifiedFold (Either c a) (Either c b)
right = forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right'
  {-# INLINE right #-}

instance ArrowApply ReifiedFold where
  app :: forall b c. ReifiedFold (ReifiedFold b c, b) c
app = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \(Fold Fold b c
bc, b
b) -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold b c
bc b
b
  {-# INLINE app #-}

instance Functor (ReifiedFold s) where
  fmap :: forall a b. (a -> b) -> ReifiedFold s a -> ReifiedFold s b
fmap a -> b
f ReifiedFold s a
l = forall s a. Fold s a -> ReifiedFold s a
Fold (forall s a. ReifiedFold s a -> Fold s a
runFold ReifiedFold s a
lforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
f)
  {-# INLINE fmap #-}

instance Apply (ReifiedFold s) where
  Fold Fold s (a -> b)
mf <.> :: forall a b.
ReifiedFold s (a -> b) -> ReifiedFold s a -> ReifiedFold s b
<.> Fold Fold s a
ma = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \s
s -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s (a -> b)
mf s
s forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
<.> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
ma s
s
  {-# INLINE (<.>) #-}
  Fold Fold s a
mf <. :: forall a b. ReifiedFold s a -> ReifiedFold s b -> ReifiedFold s a
<. Fold Fold s b
ma = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \s
s -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
mf s
s forall (f :: * -> *) a b. Apply f => f a -> f b -> f a
<. forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s b
ma s
s
  {-# INLINE (<.) #-}
  Fold Fold s a
mf .> :: forall a b. ReifiedFold s a -> ReifiedFold s b -> ReifiedFold s b
.> Fold Fold s b
ma = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \s
s -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
mf s
s forall (f :: * -> *) a b. Apply f => f a -> f b -> f b
.> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s b
ma s
s
  {-# INLINE (.>) #-}

instance Applicative (ReifiedFold s) where
  pure :: forall a. a -> ReifiedFold s a
pure a
a = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \s
_ -> [a
a]
  {-# INLINE pure #-}
  Fold Fold s (a -> b)
mf <*> :: forall a b.
ReifiedFold s (a -> b) -> ReifiedFold s a -> ReifiedFold s b
<*> Fold Fold s a
ma = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \s
s -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s (a -> b)
mf s
s forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
ma s
s
  {-# INLINE (<*>) #-}
  Fold Fold s a
mf <* :: forall a b. ReifiedFold s a -> ReifiedFold s b -> ReifiedFold s a
<* Fold Fold s b
ma = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \s
s -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
mf s
s forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s b
ma s
s
  {-# INLINE (<*) #-}
  Fold Fold s a
mf *> :: forall a b. ReifiedFold s a -> ReifiedFold s b -> ReifiedFold s b
*> Fold Fold s b
ma = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \s
s -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
mf s
s forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s b
ma s
s
  {-# INLINE (*>) #-}

instance Alternative (ReifiedFold s) where
  empty :: forall a. ReifiedFold s a
empty = forall s a. Fold s a -> ReifiedFold s a
Fold forall (f :: * -> *) pafb s. Applicative f => pafb -> s -> f s
ignored
  {-# INLINE empty #-}
  Fold Fold s a
ma <|> :: forall a. ReifiedFold s a -> ReifiedFold s a -> ReifiedFold s a
<|> Fold Fold s a
mb = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding (\s
s -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
ma s
s forall a. [a] -> [a] -> [a]
++ forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
mb s
s)
  {-# INLINE (<|>) #-}

instance Bind (ReifiedFold s) where
  Fold Fold s a
ma >>- :: forall a b.
ReifiedFold s a -> (a -> ReifiedFold s b) -> ReifiedFold s b
>>- a -> ReifiedFold s b
f = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \s
s -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
ma s
s forall (m :: * -> *) a b. Bind m => m a -> (a -> m b) -> m b
>>- \a
a -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf (forall s a. ReifiedFold s a -> Fold s a
runFold (a -> ReifiedFold s b
f a
a)) s
s
  {-# INLINE (>>-) #-}

instance Monad (ReifiedFold s) where
  return :: forall a. a -> ReifiedFold s a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
  {-# INLINE return #-}
  Fold Fold s a
ma >>= :: forall a b.
ReifiedFold s a -> (a -> ReifiedFold s b) -> ReifiedFold s b
>>= a -> ReifiedFold s b
f = forall s a. Fold s a -> ReifiedFold s a
Fold forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding forall a b. (a -> b) -> a -> b
$ \s
s -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Fold s a
ma s
s forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \a
a -> forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf (forall s a. ReifiedFold s a -> Fold s a
runFold (a -> ReifiedFold s b
f a
a)) s
s
  {-# INLINE (>>=) #-}

instance MonadPlus (ReifiedFold s) where
  mzero :: forall a. ReifiedFold s a
mzero = forall (f :: * -> *) a. Alternative f => f a
empty
  {-# INLINE mzero #-}
  mplus :: forall a. ReifiedFold s a -> ReifiedFold s a -> ReifiedFold s a
mplus = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
  {-# INLINE mplus #-}

instance MonadReader s (ReifiedFold s) where
  ask :: ReifiedFold s s
ask = forall s a. Fold s a -> ReifiedFold s a
Fold forall a. a -> a
id
  {-# INLINE ask #-}
  local :: forall a. (s -> s) -> ReifiedFold s a -> ReifiedFold s a
local s -> s
f ReifiedFold s a
m = forall s a. Fold s a -> ReifiedFold s a
Fold (forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to s -> s
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. ReifiedFold s a -> Fold s a
runFold ReifiedFold s a
m)
  {-# INLINE local #-}

instance Semigroup (ReifiedFold s a) where
  <> :: ReifiedFold s a -> ReifiedFold s a -> ReifiedFold s a
(<>) = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
  {-# INLINE (<>) #-}

instance Monoid (ReifiedFold s a) where
  mempty :: ReifiedFold s a
mempty = forall s a. Fold s a -> ReifiedFold s a
Fold forall (f :: * -> *) pafb s. Applicative f => pafb -> s -> f s
ignored
  {-# INLINE mempty #-}
#if !(MIN_VERSION_base(4,11,0))
  mappend = (<|>)
  {-# INLINE mappend #-}
#endif

instance Alt (ReifiedFold s) where
  <!> :: forall a. ReifiedFold s a -> ReifiedFold s a -> ReifiedFold s a
(<!>) = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
  {-# INLINE (<!>) #-}

instance Plus (ReifiedFold s) where
  zero :: forall a. ReifiedFold s a
zero = forall s a. Fold s a -> ReifiedFold s a
Fold forall (f :: * -> *) pafb s. Applicative f => pafb -> s -> f s
ignored
  {-# INLINE zero #-}

------------------------------------------------------------------------------
-- IndexedFold
------------------------------------------------------------------------------

newtype ReifiedIndexedFold i s a = IndexedFold { forall i s a. ReifiedIndexedFold i s a -> IndexedFold i s a
runIndexedFold :: IndexedFold i s a }

instance Semigroup (ReifiedIndexedFold i s a) where
  <> :: ReifiedIndexedFold i s a
-> ReifiedIndexedFold i s a -> ReifiedIndexedFold i s a
(<>) = forall (f :: * -> *) a. Alt f => f a -> f a -> f a
(<!>)
  {-# INLINE (<>) #-}

instance Monoid (ReifiedIndexedFold i s a) where
  mempty :: ReifiedIndexedFold i s a
mempty = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold forall (f :: * -> *) pafb s. Applicative f => pafb -> s -> f s
ignored
  {-# INLINE mempty #-}
#if !(MIN_VERSION_base(4,11,0))
  mappend = (<!>)
  {-# INLINE mappend #-}
#endif

instance Alt (ReifiedIndexedFold i s) where
  IndexedFold IndexedFold i s a
ma <!> :: forall a.
ReifiedIndexedFold i s a
-> ReifiedIndexedFold i s a -> ReifiedIndexedFold i s a
<!> IndexedFold IndexedFold i s a
mb = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold forall a b. (a -> b) -> a -> b
$
    forall (f :: * -> *) i (p :: * -> * -> *) (g :: * -> *) s a t b.
(Foldable f, Indexable i p, Contravariant g, Applicative g) =>
(s -> f (i, a)) -> Over p g s t a b
ifolding forall a b. (a -> b) -> a -> b
$ \s
s -> forall i a s. IndexedGetting i (Endo [(i, a)]) s a -> s -> [(i, a)]
itoListOf IndexedFold i s a
ma s
s forall a. [a] -> [a] -> [a]
++ forall i a s. IndexedGetting i (Endo [(i, a)]) s a -> s -> [(i, a)]
itoListOf IndexedFold i s a
mb s
s
  {-# INLINE (<!>) #-}

instance Plus (ReifiedIndexedFold i s) where
  zero :: forall a. ReifiedIndexedFold i s a
zero = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold forall (f :: * -> *) pafb s. Applicative f => pafb -> s -> f s
ignored
  {-# INLINE zero #-}

instance Functor (ReifiedIndexedFold i s) where
  fmap :: forall a b.
(a -> b) -> ReifiedIndexedFold i s a -> ReifiedIndexedFold i s b
fmap a -> b
f ReifiedIndexedFold i s a
l = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold (forall i s a. ReifiedIndexedFold i s a -> IndexedFold i s a
runIndexedFold ReifiedIndexedFold i s a
l forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
f)
  {-# INLINE fmap #-}

instance Profunctor (ReifiedIndexedFold i) where
  dimap :: forall a b c d.
(a -> b)
-> (c -> d) -> ReifiedIndexedFold i b c -> ReifiedIndexedFold i a d
dimap a -> b
f c -> d
g ReifiedIndexedFold i b c
l = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold (forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i s a. ReifiedIndexedFold i s a -> IndexedFold i s a
runIndexedFold ReifiedIndexedFold i b c
l forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to c -> d
g)
  {-# INLINE dimap #-}
  lmap :: forall a b c.
(a -> b) -> ReifiedIndexedFold i b c -> ReifiedIndexedFold i a c
lmap a -> b
f ReifiedIndexedFold i b c
l = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold (forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i s a. ReifiedIndexedFold i s a -> IndexedFold i s a
runIndexedFold ReifiedIndexedFold i b c
l)
  {-# INLINE lmap #-}
  rmap :: forall b c a.
(b -> c) -> ReifiedIndexedFold i a b -> ReifiedIndexedFold i a c
rmap b -> c
g ReifiedIndexedFold i a b
l = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold (forall i s a. ReifiedIndexedFold i s a -> IndexedFold i s a
runIndexedFold ReifiedIndexedFold i a b
l forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to b -> c
g)
  {-# INLINE rmap #-}

instance Sieve (ReifiedIndexedFold i) (Compose [] ((,) i)) where
  sieve :: forall a b. ReifiedIndexedFold i a b -> a -> Compose [] ((,) i) b
sieve (IndexedFold IndexedFold i a b
l) = forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i a s. IndexedGetting i (Endo [(i, a)]) s a -> s -> [(i, a)]
itoListOf IndexedFold i a b
l
  {-# INLINE sieve #-}

instance Representable (ReifiedIndexedFold i) where
  type Rep (ReifiedIndexedFold i) = Compose [] ((,) i)
  tabulate :: forall d c.
(d -> Rep (ReifiedIndexedFold i) c) -> ReifiedIndexedFold i d c
tabulate d -> Rep (ReifiedIndexedFold i) c
k = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold forall a b. (a -> b) -> a -> b
$ \p c (f c)
f -> forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ (forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p c (f c)
f)) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> Rep (ReifiedIndexedFold i) c
k
  {-# INLINE tabulate #-}

instance Strong (ReifiedIndexedFold i) where
  first' :: forall a b c.
ReifiedIndexedFold i a b -> ReifiedIndexedFold i (a, c) (b, c)
first' ReifiedIndexedFold i a b
l  = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold forall a b. (a -> b) -> a -> b
$ \p (b, c) (f (b, c))
f (a
s,c
c) ->
    forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall a b. (a -> b) -> a -> b
$ forall i s a. ReifiedIndexedFold i s a -> IndexedFold i s a
runIndexedFold ReifiedIndexedFold i a b
l (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (forall a b c. (a -> b -> c) -> b -> a -> c
flip (,) c
c) forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom p (b, c) (f (b, c))
f) a
s
  {-# INLINE first' #-}
  second' :: forall a b c.
ReifiedIndexedFold i a b -> ReifiedIndexedFold i (c, a) (c, b)
second' ReifiedIndexedFold i a b
l = forall i s a. IndexedFold i s a -> ReifiedIndexedFold i s a
IndexedFold forall a b. (a -> b) -> a -> b
$ \p (c, b) (f (c, b))
f (c
c,a
s) ->
    forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom forall a b. (a -> b) -> a -> b
$ forall i s a. ReifiedIndexedFold i s a -> IndexedFold i s a
runIndexedFold ReifiedIndexedFold i a b
l (forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap ((,) c
c) forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom p (c, b) (f (c, b))
f) a
s
  {-# INLINE second' #-}


------------------------------------------------------------------------------
-- Setter
------------------------------------------------------------------------------

-- | Reify a t'Setter' so it can be stored safely in a container.
newtype ReifiedSetter s t a b = Setter { forall s t a b. ReifiedSetter s t a b -> Setter s t a b
runSetter :: Setter s t a b }

-- | @
-- type 'ReifiedSetter'' = 'Simple' 'ReifiedSetter'
-- @
type ReifiedSetter' s a = ReifiedSetter s s a a

------------------------------------------------------------------------------
-- IndexedSetter
------------------------------------------------------------------------------

-- | Reify an t'IndexedSetter' so it can be stored safely in a container.
newtype ReifiedIndexedSetter i s t a b =
  IndexedSetter { forall i s t a b.
ReifiedIndexedSetter i s t a b -> IndexedSetter i s t a b
runIndexedSetter :: IndexedSetter i s t a b }

-- | @
-- type 'ReifiedIndexedSetter'' i = 'Simple' ('ReifiedIndexedSetter' i)
-- @
type ReifiedIndexedSetter' i s a = ReifiedIndexedSetter i s s a a

------------------------------------------------------------------------------
-- Iso
------------------------------------------------------------------------------

-- | Reify an t'Iso' so it can be stored safely in a container.
newtype ReifiedIso s t a b = Iso { forall s t a b. ReifiedIso s t a b -> Iso s t a b
runIso :: Iso s t a b }

-- | @
-- type 'ReifiedIso'' = 'Simple' 'ReifiedIso'
-- @
type ReifiedIso' s a = ReifiedIso s s a a

------------------------------------------------------------------------------
-- Prism
------------------------------------------------------------------------------

-- | Reify a t'Prism' so it can be stored safely in a container.
newtype ReifiedPrism s t a b = Prism { forall s t a b. ReifiedPrism s t a b -> Prism s t a b
runPrism :: Prism s t a b }

-- | @
-- type 'ReifiedPrism'' = 'Simple' 'ReifiedPrism'
-- @
type ReifiedPrism' s a = ReifiedPrism s s a a