{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Trustworthy #-}
#if __GLASGOW_HASKELL__ >= 806
{-# LANGUAGE PolyKinds #-}
#else
{-# LANGUAGE TypeInType #-}
#endif
#include "lens-common.h"
module Control.Lens.Lens
(
Lens, Lens'
, IndexedLens, IndexedLens'
, ALens, ALens'
, AnIndexedLens, AnIndexedLens'
, lens, ilens, iplens, withLens
, (%%~), (%%=)
, (%%@~), (%%@=)
, (<%@~), (<%@=)
, (<<%@~), (<<%@=)
, (&), (<&>), (??)
, (&~)
, choosing
, chosen
, alongside
, inside
, (<%~), (<+~), (<-~), (<*~), (<//~)
, (<^~), (<^^~), (<**~)
, (<||~), (<&&~), (<<>~)
, (<<%~), (<<.~), (<<?~), (<<+~), (<<-~), (<<*~)
, (<<//~), (<<^~), (<<^^~), (<<**~)
, (<<||~), (<<&&~), (<<<>~)
, (<%=), (<+=), (<-=), (<*=), (<//=)
, (<^=), (<^^=), (<**=)
, (<||=), (<&&=), (<<>=)
, (<<%=), (<<.=), (<<?=), (<<+=), (<<-=), (<<*=)
, (<<//=), (<<^=), (<<^^=), (<<**=)
, (<<||=), (<<&&=), (<<<>=)
, (<<~)
, cloneLens
, cloneIndexPreservingLens
, cloneIndexedLens
, overA
, storing
, (^#)
, (#~), (#%~), (#%%~), (<#~), (<#%~)
, (#=), (#%=), (#%%=), (<#=), (<#%=)
, devoid
, united
, head1, last1
, Context(..)
, Context'
, locus
, fusing
) where
import Prelude ()
import Control.Arrow
import Control.Comonad
import Control.Lens.Internal.Context
import Control.Lens.Internal.Prelude
import Control.Lens.Internal.Getter
import Control.Lens.Internal.Indexed
import Control.Lens.Type
import Control.Monad.State as State
import Data.Functor.Apply
import Data.Functor.Reverse
import Data.Functor.Yoneda
import Data.Semigroup.Traversable
import GHC.Exts (TYPE)
infixl 8 ^#
infixr 4 %%@~, <%@~, <<%@~, %%~, <+~, <*~, <-~, <//~, <^~, <^^~, <**~, <&&~, <||~, <<>~, <%~, <<%~, <<.~, <<?~, <#~, #~, #%~, <#%~, #%%~
, <<+~, <<-~, <<*~, <<//~, <<^~, <<^^~, <<**~, <<||~, <<&&~, <<<>~
infix 4 %%@=, <%@=, <<%@=, %%=, <+=, <*=, <-=, <//=, <^=, <^^=, <**=, <&&=, <||=, <<>=, <%=, <<%=, <<.=, <<?=, <#=, #=, #%=, <#%=, #%%=
, <<+=, <<-=, <<*=, <<//=, <<^=, <<^^=, <<**=, <<||=, <<&&=, <<<>=
infixr 2 <<~
infixl 1 ??, &~
type ALens s t a b = LensLike (Pretext (->) a b) s t a b
type ALens' s a = ALens s s a a
type AnIndexedLens i s t a b = Optical (Indexed i) (->) (Pretext (Indexed i) a b) s t a b
type AnIndexedLens' i s a = AnIndexedLens i s s a a
lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
lens :: forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens s -> a
sa s -> b -> t
sbt a -> f b
afb s
s = s -> b -> t
sbt s
s forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
afb (s -> a
sa s
s)
{-# INLINE lens #-}
withLens :: forall s t a b rep (r :: TYPE rep).
ALens s t a b -> ((s -> a) -> (s -> b -> t) -> r) -> r
withLens :: forall s t a b r.
ALens s t a b -> ((s -> a) -> (s -> b -> t) -> r) -> r
withLens ALens s t a b
l (s -> a) -> (s -> b -> t) -> r
f = (s -> a) -> (s -> b -> t) -> r
f (forall s t a b. s -> ALens s t a b -> a
^# ALens s t a b
l) (forall a b c. (a -> b -> c) -> b -> a -> c
flip (forall s t a b. ALens s t a b -> b -> s -> t
storing ALens s t a b
l))
{-# INLINE withLens #-}
iplens :: (s -> a) -> (s -> b -> t) -> IndexPreservingLens s t a b
iplens :: forall s a b t.
(s -> a) -> (s -> b -> t) -> IndexPreservingLens s t a b
iplens s -> a
sa s -> b -> t
sbt p a (f b)
pafb = forall (p :: * -> * -> *) d c.
Corepresentable p =>
(Corep p d -> c) -> p d c
cotabulate forall a b. (a -> b) -> a -> b
$ \Corep p s
ws -> s -> b -> t
sbt (forall (w :: * -> *) a. Comonad w => w a -> a
extract Corep p s
ws) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: * -> * -> *) (f :: * -> *) a b.
Cosieve p f =>
p a b -> f a -> b
cosieve p a (f b)
pafb (s -> a
sa forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Corep p s
ws)
{-# INLINE iplens #-}
ilens :: (s -> (i, a)) -> (s -> b -> t) -> IndexedLens i s t a b
ilens :: forall s i a b t.
(s -> (i, a)) -> (s -> b -> t) -> IndexedLens i s t a b
ilens s -> (i, a)
sia s -> b -> t
sbt p a (f b)
iafb s
s = s -> b -> t
sbt s
s forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> 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 a (f b)
iafb) (s -> (i, a)
sia s
s)
{-# INLINE ilens #-}
(&~) :: s -> State s a -> s
s
s &~ :: forall s a. s -> State s a -> s
&~ State s a
l = forall s a. State s a -> s -> s
execState State s a
l s
s
{-# INLINE (&~) #-}
(%%~) :: LensLike f s t a b -> (a -> f b) -> s -> f t
%%~ :: forall {k} (f :: k -> *) s (t :: k) a (b :: k).
LensLike f s t a b -> LensLike f s t a b
(%%~) = forall a. a -> a
id
{-# INLINE (%%~) #-}
(%%=) :: MonadState s m => Over p ((,) r) s s a b -> p a (r, b) -> m r
Over p ((,) r) s s a b
l %%= :: forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= p a (r, b)
f = forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
State.state (Over p ((,) r) s s a b
l p a (r, b)
f)
{-# INLINE (%%=) #-}
(??) :: Functor f => f (a -> b) -> a -> f b
f (a -> b)
fab ?? :: forall (f :: * -> *) a b. Functor f => f (a -> b) -> a -> f b
?? a
a = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b. (a -> b) -> a -> b
$ a
a) f (a -> b)
fab
{-# INLINE (??) #-}
inside :: Corepresentable p => ALens s t a b -> Lens (p e s) (p e t) (p e a) (p e b)
inside :: forall (p :: * -> * -> *) s t a b e.
Corepresentable p =>
ALens s t a b -> Lens (p e s) (p e t) (p e a) (p e b)
inside ALens s t a b
l p e a -> f (p e b)
f p e s
es = p e b -> p e t
o forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> p e a -> f (p e b)
f p e a
i where
i :: p e a
i = forall (p :: * -> * -> *) d c.
Corepresentable p =>
(Corep p d -> c) -> p d c
cotabulate forall a b. (a -> b) -> a -> b
$ \ Corep p e
e -> forall (w :: * -> * -> * -> *) a c t.
IndexedComonadStore w =>
w a c t -> a
ipos forall a b. (a -> b) -> a -> b
$ ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell (forall (p :: * -> * -> *) (f :: * -> *) a b.
Cosieve p f =>
p a b -> f a -> b
cosieve p e s
es Corep p e
e)
o :: p e b -> p e t
o p e b
ea = forall (p :: * -> * -> *) d c.
Corepresentable p =>
(Corep p d -> c) -> p d c
cotabulate forall a b. (a -> b) -> a -> b
$ \ Corep p e
e -> forall (w :: * -> * -> * -> *) c a t.
IndexedComonadStore w =>
c -> w a c t -> t
ipeek (forall (p :: * -> * -> *) (f :: * -> *) a b.
Cosieve p f =>
p a b -> f a -> b
cosieve p e b
ea Corep p e
e) forall a b. (a -> b) -> a -> b
$ ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell (forall (p :: * -> * -> *) (f :: * -> *) a b.
Cosieve p f =>
p a b -> f a -> b
cosieve p e s
es Corep p e
e)
{-# INLINE inside #-}
choosing :: Functor f
=> LensLike f s t a b
-> LensLike f s' t' a b
-> LensLike f (Either s s') (Either t t') a b
choosing :: forall (f :: * -> *) s t a b s' t'.
Functor f =>
LensLike f s t a b
-> LensLike f s' t' a b
-> LensLike f (Either s s') (Either t t') a b
choosing LensLike f s t a b
l LensLike f s' t' a b
_ a -> f b
f (Left s
a) = forall a b. a -> Either a b
Left forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LensLike f s t a b
l a -> f b
f s
a
choosing LensLike f s t a b
_ LensLike f s' t' a b
r a -> f b
f (Right s'
a') = forall a b. b -> Either a b
Right forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LensLike f s' t' a b
r a -> f b
f s'
a'
{-# INLINE choosing #-}
chosen :: IndexPreservingLens (Either a a) (Either b b) a b
chosen :: forall a b. IndexPreservingLens (Either a a) (Either b b) a b
chosen p a (f b)
pafb = forall (p :: * -> * -> *) d c.
Corepresentable p =>
(Corep p d -> c) -> p d c
cotabulate forall a b. (a -> b) -> a -> b
$ \Corep p (Either a a)
weaa -> forall (p :: * -> * -> *) (f :: * -> *) a b.
Cosieve p f =>
p a b -> f a -> b
cosieve (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
`lmap` p a (f b)
pafb) Corep p (Either a a)
weaa forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \b
b -> case forall (w :: * -> *) a. Comonad w => w a -> a
extract Corep p (Either a a)
weaa of
Left a
_ -> forall a b. a -> Either a b
Left b
b
Right a
_ -> forall a b. b -> Either a b
Right b
b
{-# INLINE chosen #-}
alongside :: LensLike (AlongsideLeft f b') s t a b
-> LensLike (AlongsideRight f t) s' t' a' b'
-> LensLike f (s, s') (t, t') (a, a') (b, b')
alongside :: forall (f :: * -> *) b' s t a b s' t' a'.
LensLike (AlongsideLeft f b') s t a b
-> LensLike (AlongsideRight f t) s' t' a' b'
-> LensLike f (s, s') (t, t') (a, a') (b, b')
alongside LensLike (AlongsideLeft f b') s t a b
l1 LensLike (AlongsideRight f t) s' t' a' b'
l2 (a, a') -> f (b, b')
f (s
a1, s'
a2)
= forall (f :: * -> *) a b. AlongsideRight f a b -> f (a, b)
getAlongsideRight forall a b. (a -> b) -> a -> b
$ LensLike (AlongsideRight f t) s' t' a' b'
l2 forall (f :: * -> *) a b. Functor f => f (a -> b) -> a -> f b
?? s'
a2 forall a b. (a -> b) -> a -> b
$ \a'
b2 -> forall (f :: * -> *) a b. f (a, b) -> AlongsideRight f a b
AlongsideRight
forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) b a. AlongsideLeft f b a -> f (a, b)
getAlongsideLeft forall a b. (a -> b) -> a -> b
$ LensLike (AlongsideLeft f b') s t a b
l1 forall (f :: * -> *) a b. Functor f => f (a -> b) -> a -> f b
?? s
a1 forall a b. (a -> b) -> a -> b
$ \a
b1 -> forall (f :: * -> *) b a. f (a, b) -> AlongsideLeft f b a
AlongsideLeft
forall a b. (a -> b) -> a -> b
$ (a, a') -> f (b, b')
f (a
b1,a'
b2)
{-# INLINE alongside #-}
locus :: IndexedComonadStore p => Lens (p a c s) (p b c s) a b
locus :: forall (p :: * -> * -> * -> *) a c s b.
IndexedComonadStore p =>
Lens (p a c s) (p b c s) a b
locus a -> f b
f p a c s
w = (forall (w :: * -> * -> * -> *) b a c t.
IndexedComonadStore w =>
b -> w a c t -> w b c t
`iseek` p a c s
w) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f (forall (w :: * -> * -> * -> *) a c t.
IndexedComonadStore w =>
w a c t -> a
ipos p a c s
w)
{-# INLINE locus #-}
cloneLens :: ALens s t a b -> Lens s t a b
cloneLens :: forall s t a b. ALens s t a b -> Lens s t a b
cloneLens ALens s t a b
l a -> f b
afb s
s = forall (p :: * -> * -> *) a b t.
Pretext p a b t
-> forall (f :: * -> *). Functor f => p a (f b) -> f t
runPretext (ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s) a -> f b
afb
{-# INLINE cloneLens #-}
cloneIndexPreservingLens :: ALens s t a b -> IndexPreservingLens s t a b
cloneIndexPreservingLens :: forall s t a b. ALens s t a b -> IndexPreservingLens s t a b
cloneIndexPreservingLens ALens s t a b
l p a (f b)
pafb = forall (p :: * -> * -> *) d c.
Corepresentable p =>
(Corep p d -> c) -> p d c
cotabulate forall a b. (a -> b) -> a -> b
$ \Corep p s
ws -> forall (p :: * -> * -> *) a b t.
Pretext p a b t
-> forall (f :: * -> *). Functor f => p a (f b) -> f t
runPretext (ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell (forall (w :: * -> *) a. Comonad w => w a -> a
extract Corep p s
ws)) forall a b. (a -> b) -> a -> b
$ \a
a -> forall (p :: * -> * -> *) (f :: * -> *) a b.
Cosieve p f =>
p a b -> f a -> b
cosieve p a (f b)
pafb (a
a forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Corep p s
ws)
{-# INLINE cloneIndexPreservingLens #-}
cloneIndexedLens :: AnIndexedLens i s t a b -> IndexedLens i s t a b
cloneIndexedLens :: forall i s t a b. AnIndexedLens i s t a b -> IndexedLens i s t a b
cloneIndexedLens AnIndexedLens i s t a b
l p a (f b)
f s
s = forall (p :: * -> * -> *) a b t.
Pretext p a b t
-> forall (f :: * -> *). Functor f => p a (f b) -> f t
runPretext (AnIndexedLens i s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s) (forall i a b. (i -> a -> b) -> Indexed i a b
Indexed (forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p a (f b)
f))
{-# INLINE cloneIndexedLens #-}
(<%~) :: LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
LensLike ((,) b) s t a b
l <%~ :: forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ a -> b
f = LensLike ((,) b) s t a b
l forall a b. (a -> b) -> a -> b
$ (\b
t -> (b
t, b
t)) forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f
{-# INLINE (<%~) #-}
(<+~) :: Num a => LensLike ((,)a) s t a a -> a -> s -> (a, t)
LensLike ((,) a) s t a a
l <+~ :: forall a s t. Num a => LensLike ((,) a) s t a a -> a -> s -> (a, t)
<+~ a
a = LensLike ((,) a) s t a a
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ (forall a. Num a => a -> a -> a
+ a
a)
{-# INLINE (<+~) #-}
(<-~) :: Num a => LensLike ((,)a) s t a a -> a -> s -> (a, t)
LensLike ((,) a) s t a a
l <-~ :: forall a s t. Num a => LensLike ((,) a) s t a a -> a -> s -> (a, t)
<-~ a
a = LensLike ((,) a) s t a a
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ forall a. Num a => a -> a -> a
subtract a
a
{-# INLINE (<-~) #-}
(<*~) :: Num a => LensLike ((,)a) s t a a -> a -> s -> (a, t)
LensLike ((,) a) s t a a
l <*~ :: forall a s t. Num a => LensLike ((,) a) s t a a -> a -> s -> (a, t)
<*~ a
a = LensLike ((,) a) s t a a
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ (forall a. Num a => a -> a -> a
* a
a)
{-# INLINE (<*~) #-}
(<//~) :: Fractional a => LensLike ((,)a) s t a a -> a -> s -> (a, t)
LensLike ((,) a) s t a a
l <//~ :: forall a s t.
Fractional a =>
LensLike ((,) a) s t a a -> a -> s -> (a, t)
<//~ a
a = LensLike ((,) a) s t a a
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ (forall a. Fractional a => a -> a -> a
/ a
a)
{-# INLINE (<//~) #-}
(<^~) :: (Num a, Integral e) => LensLike ((,)a) s t a a -> e -> s -> (a, t)
LensLike ((,) a) s t a a
l <^~ :: forall a e s t.
(Num a, Integral e) =>
LensLike ((,) a) s t a a -> e -> s -> (a, t)
<^~ e
e = LensLike ((,) a) s t a a
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ (forall a b. (Num a, Integral b) => a -> b -> a
^ e
e)
{-# INLINE (<^~) #-}
(<^^~) :: (Fractional a, Integral e) => LensLike ((,)a) s t a a -> e -> s -> (a, t)
LensLike ((,) a) s t a a
l <^^~ :: forall a e s t.
(Fractional a, Integral e) =>
LensLike ((,) a) s t a a -> e -> s -> (a, t)
<^^~ e
e = LensLike ((,) a) s t a a
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ (forall a b. (Fractional a, Integral b) => a -> b -> a
^^ e
e)
{-# INLINE (<^^~) #-}
(<**~) :: Floating a => LensLike ((,)a) s t a a -> a -> s -> (a, t)
LensLike ((,) a) s t a a
l <**~ :: forall a s t.
Floating a =>
LensLike ((,) a) s t a a -> a -> s -> (a, t)
<**~ a
a = LensLike ((,) a) s t a a
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ (forall a. Floating a => a -> a -> a
** a
a)
{-# INLINE (<**~) #-}
(<||~) :: LensLike ((,)Bool) s t Bool Bool -> Bool -> s -> (Bool, t)
LensLike ((,) Bool) s t Bool Bool
l <||~ :: forall s t.
LensLike ((,) Bool) s t Bool Bool -> Bool -> s -> (Bool, t)
<||~ Bool
b = LensLike ((,) Bool) s t Bool Bool
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ (Bool -> Bool -> Bool
|| Bool
b)
{-# INLINE (<||~) #-}
(<&&~) :: LensLike ((,)Bool) s t Bool Bool -> Bool -> s -> (Bool, t)
LensLike ((,) Bool) s t Bool Bool
l <&&~ :: forall s t.
LensLike ((,) Bool) s t Bool Bool -> Bool -> s -> (Bool, t)
<&&~ Bool
b = LensLike ((,) Bool) s t Bool Bool
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ (Bool -> Bool -> Bool
&& Bool
b)
{-# INLINE (<&&~) #-}
(<<%~) :: LensLike ((,)a) s t a b -> (a -> b) -> s -> (a, t)
<<%~ :: forall a s t b. LensLike ((,) a) s t a b -> (a -> b) -> s -> (a, t)
(<<%~) LensLike ((,) a) s t a b
l = LensLike ((,) a) s t a b
l forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap (\a
a -> (a
a, a
a)) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Strong p =>
p a b -> p (c, a) (c, b)
second'
{-# INLINE (<<%~) #-}
(<<.~) :: LensLike ((,)a) s t a b -> b -> s -> (a, t)
LensLike ((,) a) s t a b
l <<.~ :: forall a s t b. LensLike ((,) a) s t a b -> b -> s -> (a, t)
<<.~ b
b = LensLike ((,) a) s t a b
l forall a b. (a -> b) -> a -> b
$ \a
a -> (a
a, b
b)
{-# INLINE (<<.~) #-}
(<<?~) :: LensLike ((,)a) s t a (Maybe b) -> b -> s -> (a, t)
LensLike ((,) a) s t a (Maybe b)
l <<?~ :: forall a s t b.
LensLike ((,) a) s t a (Maybe b) -> b -> s -> (a, t)
<<?~ b
b = LensLike ((,) a) s t a (Maybe b)
l forall a s t b. LensLike ((,) a) s t a b -> b -> s -> (a, t)
<<.~ forall a. a -> Maybe a
Just b
b
{-# INLINE (<<?~) #-}
(<<+~) :: Num a => LensLike' ((,) a) s a -> a -> s -> (a, s)
LensLike' ((,) a) s a
l <<+~ :: forall a s. Num a => LensLike' ((,) a) s a -> a -> s -> (a, s)
<<+~ a
b = LensLike' ((,) a) s a
l forall a b. (a -> b) -> a -> b
$ \a
a -> (a
a, a
a forall a. Num a => a -> a -> a
+ a
b)
{-# INLINE (<<+~) #-}
(<<-~) :: Num a => LensLike' ((,) a) s a -> a -> s -> (a, s)
LensLike' ((,) a) s a
l <<-~ :: forall a s. Num a => LensLike' ((,) a) s a -> a -> s -> (a, s)
<<-~ a
b = LensLike' ((,) a) s a
l forall a b. (a -> b) -> a -> b
$ \a
a -> (a
a, a
a forall a. Num a => a -> a -> a
- a
b)
{-# INLINE (<<-~) #-}
(<<*~) :: Num a => LensLike' ((,) a) s a -> a -> s -> (a, s)
LensLike' ((,) a) s a
l <<*~ :: forall a s. Num a => LensLike' ((,) a) s a -> a -> s -> (a, s)
<<*~ a
b = LensLike' ((,) a) s a
l forall a b. (a -> b) -> a -> b
$ \a
a -> (a
a, a
a forall a. Num a => a -> a -> a
* a
b)
{-# INLINE (<<*~) #-}
(<<//~) :: Fractional a => LensLike' ((,) a) s a -> a -> s -> (a, s)
LensLike' ((,) a) s a
l <<//~ :: forall a s.
Fractional a =>
LensLike' ((,) a) s a -> a -> s -> (a, s)
<<//~ a
b = LensLike' ((,) a) s a
l forall a b. (a -> b) -> a -> b
$ \a
a -> (a
a, a
a forall a. Fractional a => a -> a -> a
/ a
b)
{-# INLINE (<<//~) #-}
(<<^~) :: (Num a, Integral e) => LensLike' ((,) a) s a -> e -> s -> (a, s)
LensLike' ((,) a) s a
l <<^~ :: forall a e s.
(Num a, Integral e) =>
LensLike' ((,) a) s a -> e -> s -> (a, s)
<<^~ e
e = LensLike' ((,) a) s a
l forall a b. (a -> b) -> a -> b
$ \a
a -> (a
a, a
a forall a b. (Num a, Integral b) => a -> b -> a
^ e
e)
{-# INLINE (<<^~) #-}
(<<^^~) :: (Fractional a, Integral e) => LensLike' ((,) a) s a -> e -> s -> (a, s)
LensLike' ((,) a) s a
l <<^^~ :: forall a e s.
(Fractional a, Integral e) =>
LensLike' ((,) a) s a -> e -> s -> (a, s)
<<^^~ e
e = LensLike' ((,) a) s a
l forall a b. (a -> b) -> a -> b
$ \a
a -> (a
a, a
a forall a b. (Fractional a, Integral b) => a -> b -> a
^^ e
e)
{-# INLINE (<<^^~) #-}
(<<**~) :: Floating a => LensLike' ((,) a) s a -> a -> s -> (a, s)
LensLike' ((,) a) s a
l <<**~ :: forall a s. Floating a => LensLike' ((,) a) s a -> a -> s -> (a, s)
<<**~ a
e = LensLike' ((,) a) s a
l forall a b. (a -> b) -> a -> b
$ \a
a -> (a
a, a
a forall a. Floating a => a -> a -> a
** a
e)
{-# INLINE (<<**~) #-}
(<<||~) :: LensLike' ((,) Bool) s Bool -> Bool -> s -> (Bool, s)
LensLike' ((,) Bool) s Bool
l <<||~ :: forall s. LensLike' ((,) Bool) s Bool -> Bool -> s -> (Bool, s)
<<||~ Bool
b = LensLike' ((,) Bool) s Bool
l forall a b. (a -> b) -> a -> b
$ \Bool
a -> (Bool
a, Bool
b Bool -> Bool -> Bool
|| Bool
a)
{-# INLINE (<<||~) #-}
(<<&&~) :: LensLike' ((,) Bool) s Bool -> Bool -> s -> (Bool, s)
LensLike' ((,) Bool) s Bool
l <<&&~ :: forall s. LensLike' ((,) Bool) s Bool -> Bool -> s -> (Bool, s)
<<&&~ Bool
b = LensLike' ((,) Bool) s Bool
l forall a b. (a -> b) -> a -> b
$ \Bool
a -> (Bool
a, Bool
b Bool -> Bool -> Bool
&& Bool
a)
{-# INLINE (<<&&~) #-}
(<<<>~) :: Semigroup r => LensLike' ((,) r) s r -> r -> s -> (r, s)
LensLike' ((,) r) s r
l <<<>~ :: forall r s.
Semigroup r =>
LensLike' ((,) r) s r -> r -> s -> (r, s)
<<<>~ r
b = LensLike' ((,) r) s r
l forall a b. (a -> b) -> a -> b
$ \r
a -> (r
a, r
a forall a. Semigroup a => a -> a -> a
<> r
b)
{-# INLINE (<<<>~) #-}
(<%=) :: MonadState s m => LensLike ((,)b) s s a b -> (a -> b) -> m b
LensLike ((,) b) s s a b
l <%= :: forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= a -> b
f = LensLike ((,) b) s s a b
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= (\b
b -> (b
b, b
b)) forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f
{-# INLINE (<%=) #-}
(<+=) :: (MonadState s m, Num a) => LensLike' ((,)a) s a -> a -> m a
LensLike' ((,) a) s a
l <+= :: forall s (m :: * -> *) a.
(MonadState s m, Num a) =>
LensLike' ((,) a) s a -> a -> m a
<+= a
a = LensLike' ((,) a) s a
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= (forall a. Num a => a -> a -> a
+ a
a)
{-# INLINE (<+=) #-}
(<-=) :: (MonadState s m, Num a) => LensLike' ((,)a) s a -> a -> m a
LensLike' ((,) a) s a
l <-= :: forall s (m :: * -> *) a.
(MonadState s m, Num a) =>
LensLike' ((,) a) s a -> a -> m a
<-= a
a = LensLike' ((,) a) s a
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= forall a. Num a => a -> a -> a
subtract a
a
{-# INLINE (<-=) #-}
(<*=) :: (MonadState s m, Num a) => LensLike' ((,)a) s a -> a -> m a
LensLike' ((,) a) s a
l <*= :: forall s (m :: * -> *) a.
(MonadState s m, Num a) =>
LensLike' ((,) a) s a -> a -> m a
<*= a
a = LensLike' ((,) a) s a
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= (forall a. Num a => a -> a -> a
* a
a)
{-# INLINE (<*=) #-}
(<//=) :: (MonadState s m, Fractional a) => LensLike' ((,)a) s a -> a -> m a
LensLike' ((,) a) s a
l <//= :: forall s (m :: * -> *) a.
(MonadState s m, Fractional a) =>
LensLike' ((,) a) s a -> a -> m a
<//= a
a = LensLike' ((,) a) s a
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= (forall a. Fractional a => a -> a -> a
/ a
a)
{-# INLINE (<//=) #-}
(<^=) :: (MonadState s m, Num a, Integral e) => LensLike' ((,)a) s a -> e -> m a
LensLike' ((,) a) s a
l <^= :: forall s (m :: * -> *) a e.
(MonadState s m, Num a, Integral e) =>
LensLike' ((,) a) s a -> e -> m a
<^= e
e = LensLike' ((,) a) s a
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= (forall a b. (Num a, Integral b) => a -> b -> a
^ e
e)
{-# INLINE (<^=) #-}
(<^^=) :: (MonadState s m, Fractional a, Integral e) => LensLike' ((,)a) s a -> e -> m a
LensLike' ((,) a) s a
l <^^= :: forall s (m :: * -> *) a e.
(MonadState s m, Fractional a, Integral e) =>
LensLike' ((,) a) s a -> e -> m a
<^^= e
e = LensLike' ((,) a) s a
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= (forall a b. (Fractional a, Integral b) => a -> b -> a
^^ e
e)
{-# INLINE (<^^=) #-}
(<**=) :: (MonadState s m, Floating a) => LensLike' ((,)a) s a -> a -> m a
LensLike' ((,) a) s a
l <**= :: forall s (m :: * -> *) a.
(MonadState s m, Floating a) =>
LensLike' ((,) a) s a -> a -> m a
<**= a
a = LensLike' ((,) a) s a
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= (forall a. Floating a => a -> a -> a
** a
a)
{-# INLINE (<**=) #-}
(<||=) :: MonadState s m => LensLike' ((,)Bool) s Bool -> Bool -> m Bool
LensLike' ((,) Bool) s Bool
l <||= :: forall s (m :: * -> *).
MonadState s m =>
LensLike' ((,) Bool) s Bool -> Bool -> m Bool
<||= Bool
b = LensLike' ((,) Bool) s Bool
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= (Bool -> Bool -> Bool
|| Bool
b)
{-# INLINE (<||=) #-}
(<&&=) :: MonadState s m => LensLike' ((,)Bool) s Bool -> Bool -> m Bool
LensLike' ((,) Bool) s Bool
l <&&= :: forall s (m :: * -> *).
MonadState s m =>
LensLike' ((,) Bool) s Bool -> Bool -> m Bool
<&&= Bool
b = LensLike' ((,) Bool) s Bool
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= (Bool -> Bool -> Bool
&& Bool
b)
{-# INLINE (<&&=) #-}
(<<%=) :: (Strong p, MonadState s m) => Over p ((,)a) s s a b -> p a b -> m a
Over p ((,) a) s s a b
l <<%= :: forall (p :: * -> * -> *) s (m :: * -> *) a b.
(Strong p, MonadState s m) =>
Over p ((,) a) s s a b -> p a b -> m a
<<%= p a b
f = Over p ((,) a) s s a b
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= forall (p :: * -> * -> *) a b c.
Profunctor p =>
(a -> b) -> p b c -> p a c
lmap (\a
a -> (a
a,a
a)) (forall (p :: * -> * -> *) a b c.
Strong p =>
p a b -> p (c, a) (c, b)
second' p a b
f)
{-# INLINE (<<%=) #-}
(<<.=) :: MonadState s m => LensLike ((,)a) s s a b -> b -> m a
LensLike ((,) a) s s a b
l <<.= :: forall s (m :: * -> *) a b.
MonadState s m =>
LensLike ((,) a) s s a b -> b -> m a
<<.= b
b = LensLike ((,) a) s s a b
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \a
a -> (a
a,b
b)
{-# INLINE (<<.=) #-}
(<<?=) :: MonadState s m => LensLike ((,)a) s s a (Maybe b) -> b -> m a
LensLike ((,) a) s s a (Maybe b)
l <<?= :: forall s (m :: * -> *) a b.
MonadState s m =>
LensLike ((,) a) s s a (Maybe b) -> b -> m a
<<?= b
b = LensLike ((,) a) s s a (Maybe b)
l forall s (m :: * -> *) a b.
MonadState s m =>
LensLike ((,) a) s s a b -> b -> m a
<<.= forall a. a -> Maybe a
Just b
b
{-# INLINE (<<?=) #-}
(<<+=) :: (MonadState s m, Num a) => LensLike' ((,) a) s a -> a -> m a
LensLike' ((,) a) s a
l <<+= :: forall s (m :: * -> *) a.
(MonadState s m, Num a) =>
LensLike' ((,) a) s a -> a -> m a
<<+= a
n = LensLike' ((,) a) s a
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \a
a -> (a
a, a
a forall a. Num a => a -> a -> a
+ a
n)
{-# INLINE (<<+=) #-}
(<<-=) :: (MonadState s m, Num a) => LensLike' ((,) a) s a -> a -> m a
LensLike' ((,) a) s a
l <<-= :: forall s (m :: * -> *) a.
(MonadState s m, Num a) =>
LensLike' ((,) a) s a -> a -> m a
<<-= a
n = LensLike' ((,) a) s a
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \a
a -> (a
a, a
a forall a. Num a => a -> a -> a
- a
n)
{-# INLINE (<<-=) #-}
(<<*=) :: (MonadState s m, Num a) => LensLike' ((,) a) s a -> a -> m a
LensLike' ((,) a) s a
l <<*= :: forall s (m :: * -> *) a.
(MonadState s m, Num a) =>
LensLike' ((,) a) s a -> a -> m a
<<*= a
n = LensLike' ((,) a) s a
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \a
a -> (a
a, a
a forall a. Num a => a -> a -> a
* a
n)
{-# INLINE (<<*=) #-}
(<<//=) :: (MonadState s m, Fractional a) => LensLike' ((,) a) s a -> a -> m a
LensLike' ((,) a) s a
l <<//= :: forall s (m :: * -> *) a.
(MonadState s m, Fractional a) =>
LensLike' ((,) a) s a -> a -> m a
<<//= a
n = LensLike' ((,) a) s a
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \a
a -> (a
a, a
a forall a. Fractional a => a -> a -> a
/ a
n)
{-# INLINE (<<//=) #-}
(<<^=) :: (MonadState s m, Num a, Integral e) => LensLike' ((,) a) s a -> e -> m a
LensLike' ((,) a) s a
l <<^= :: forall s (m :: * -> *) a e.
(MonadState s m, Num a, Integral e) =>
LensLike' ((,) a) s a -> e -> m a
<<^= e
n = LensLike' ((,) a) s a
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \a
a -> (a
a, a
a forall a b. (Num a, Integral b) => a -> b -> a
^ e
n)
{-# INLINE (<<^=) #-}
(<<^^=) :: (MonadState s m, Fractional a, Integral e) => LensLike' ((,) a) s a -> e -> m a
LensLike' ((,) a) s a
l <<^^= :: forall s (m :: * -> *) a e.
(MonadState s m, Fractional a, Integral e) =>
LensLike' ((,) a) s a -> e -> m a
<<^^= e
n = LensLike' ((,) a) s a
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \a
a -> (a
a, a
a forall a b. (Fractional a, Integral b) => a -> b -> a
^^ e
n)
{-# INLINE (<<^^=) #-}
(<<**=) :: (MonadState s m, Floating a) => LensLike' ((,) a) s a -> a -> m a
LensLike' ((,) a) s a
l <<**= :: forall s (m :: * -> *) a.
(MonadState s m, Floating a) =>
LensLike' ((,) a) s a -> a -> m a
<<**= a
n = LensLike' ((,) a) s a
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \a
a -> (a
a, a
a forall a. Floating a => a -> a -> a
** a
n)
{-# INLINE (<<**=) #-}
(<<||=) :: MonadState s m => LensLike' ((,) Bool) s Bool -> Bool -> m Bool
LensLike' ((,) Bool) s Bool
l <<||= :: forall s (m :: * -> *).
MonadState s m =>
LensLike' ((,) Bool) s Bool -> Bool -> m Bool
<<||= Bool
b = LensLike' ((,) Bool) s Bool
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \Bool
a -> (Bool
a, Bool
a Bool -> Bool -> Bool
|| Bool
b)
{-# INLINE (<<||=) #-}
(<<&&=) :: MonadState s m => LensLike' ((,) Bool) s Bool -> Bool -> m Bool
LensLike' ((,) Bool) s Bool
l <<&&= :: forall s (m :: * -> *).
MonadState s m =>
LensLike' ((,) Bool) s Bool -> Bool -> m Bool
<<&&= Bool
b = LensLike' ((,) Bool) s Bool
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \Bool
a -> (Bool
a, Bool
a Bool -> Bool -> Bool
&& Bool
b)
{-# INLINE (<<&&=) #-}
(<<<>=) :: (MonadState s m, Semigroup r) => LensLike' ((,) r) s r -> r -> m r
LensLike' ((,) r) s r
l <<<>= :: forall s (m :: * -> *) r.
(MonadState s m, Semigroup r) =>
LensLike' ((,) r) s r -> r -> m r
<<<>= r
b = LensLike' ((,) r) s r
l forall {k} s (m :: * -> *) (p :: k -> * -> *) r (a :: k) b.
MonadState s m =>
Over p ((,) r) s s a b -> p a (r, b) -> m r
%%= \r
a -> (r
a, r
a forall a. Semigroup a => a -> a -> a
<> r
b)
{-# INLINE (<<<>=) #-}
(<<~) :: MonadState s m => ALens s s a b -> m b -> m b
ALens s s a b
l <<~ :: forall s (m :: * -> *) a b.
MonadState s m =>
ALens s s a b -> m b -> m b
<<~ m b
mb = do
b
b <- m b
mb
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall a b. (a -> b) -> a -> b
$ \s
s -> forall (w :: * -> * -> * -> *) c a t.
IndexedComonadStore w =>
c -> w a c t -> t
ipeek b
b (ALens s s a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s)
forall (m :: * -> *) a. Monad m => a -> m a
return b
b
{-# INLINE (<<~) #-}
(<<>~) :: Semigroup m => LensLike ((,)m) s t m m -> m -> s -> (m, t)
LensLike ((,) m) s t m m
l <<>~ :: forall m s t.
Semigroup m =>
LensLike ((,) m) s t m m -> m -> s -> (m, t)
<<>~ m
m = LensLike ((,) m) s t m m
l forall b s t a. LensLike ((,) b) s t a b -> (a -> b) -> s -> (b, t)
<%~ (forall a. Semigroup a => a -> a -> a
<> m
m)
{-# INLINE (<<>~) #-}
(<<>=) :: (MonadState s m, Semigroup r) => LensLike' ((,)r) s r -> r -> m r
LensLike' ((,) r) s r
l <<>= :: forall s (m :: * -> *) r.
(MonadState s m, Semigroup r) =>
LensLike' ((,) r) s r -> r -> m r
<<>= r
r = LensLike' ((,) r) s r
l forall s (m :: * -> *) b a.
MonadState s m =>
LensLike ((,) b) s s a b -> (a -> b) -> m b
<%= (forall a. Semigroup a => a -> a -> a
<> r
r)
{-# INLINE (<<>=) #-}
overA :: Arrow ar => LensLike (Context a b) s t a b -> ar a b -> ar s t
overA :: forall (ar :: * -> * -> *) a b s t.
Arrow ar =>
LensLike (Context a b) s t a b -> ar a b -> ar s t
overA LensLike (Context a b) s t a b
l ar a b
p = forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (\s
s -> let (Context b -> t
f a
a) = LensLike (Context a b) s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s in (b -> t
f, a
a))
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second ar a b
p
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall a. a -> a
id)
(<%@~) :: Over (Indexed i) ((,) b) s t a b -> (i -> a -> b) -> s -> (b, t)
Over (Indexed i) ((,) b) s t a b
l <%@~ :: forall i b s t a.
Over (Indexed i) ((,) b) s t a b -> (i -> a -> b) -> s -> (b, t)
<%@~ i -> a -> b
f = Over (Indexed i) ((,) b) s t a b
l (forall i a b. (i -> a -> b) -> Indexed i a b
Indexed forall a b. (a -> b) -> a -> b
$ \i
i a
a -> let b :: b
b = i -> a -> b
f i
i a
a in (b
b, b
b))
{-# INLINE (<%@~) #-}
(<<%@~) :: Over (Indexed i) ((,) a) s t a b -> (i -> a -> b) -> s -> (a, t)
Over (Indexed i) ((,) a) s t a b
l <<%@~ :: forall i a s t b.
Over (Indexed i) ((,) a) s t a b -> (i -> a -> b) -> s -> (a, t)
<<%@~ i -> a -> b
f = Over (Indexed i) ((,) a) s t a b
l forall a b. (a -> b) -> a -> b
$ forall i a b. (i -> a -> b) -> Indexed i a b
Indexed forall a b. (a -> b) -> a -> b
$ \i
i a
a -> forall (p :: * -> * -> *) a b c.
Strong p =>
p a b -> p (c, a) (c, b)
second' (i -> a -> b
f i
i) (a
a,a
a)
{-# INLINE (<<%@~) #-}
(%%@~) :: Over (Indexed i) f s t a b -> (i -> a -> f b) -> s -> f t
%%@~ :: forall {k} i (f :: k -> *) s (t :: k) a (b :: k).
Over (Indexed i) f s t a b -> (i -> a -> f b) -> s -> f t
(%%@~) Over (Indexed i) f s t a b
l = Over (Indexed i) f s t a b
l forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# forall i a b. (i -> a -> b) -> Indexed i a b
Indexed
{-# INLINE (%%@~) #-}
(%%@=) :: MonadState s m => Over (Indexed i) ((,) r) s s a b -> (i -> a -> (r, b)) -> m r
Over (Indexed i) ((,) r) s s a b
l %%@= :: forall s (m :: * -> *) i r a b.
MonadState s m =>
Over (Indexed i) ((,) r) s s a b -> (i -> a -> (r, b)) -> m r
%%@= i -> a -> (r, b)
f = forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
State.state (Over (Indexed i) ((,) r) s s a b
l forall {k} i (f :: k -> *) s (t :: k) a (b :: k).
Over (Indexed i) f s t a b -> (i -> a -> f b) -> s -> f t
%%@~ i -> a -> (r, b)
f)
{-# INLINE (%%@=) #-}
(<%@=) :: MonadState s m => Over (Indexed i) ((,) b) s s a b -> (i -> a -> b) -> m b
Over (Indexed i) ((,) b) s s a b
l <%@= :: forall s (m :: * -> *) i b a.
MonadState s m =>
Over (Indexed i) ((,) b) s s a b -> (i -> a -> b) -> m b
<%@= i -> a -> b
f = Over (Indexed i) ((,) b) s s a b
l forall s (m :: * -> *) i r a b.
MonadState s m =>
Over (Indexed i) ((,) r) s s a b -> (i -> a -> (r, b)) -> m r
%%@= \ i
i a
a -> let b :: b
b = i -> a -> b
f i
i a
a in (b
b, b
b)
{-# INLINE (<%@=) #-}
(<<%@=) :: MonadState s m => Over (Indexed i) ((,) a) s s a b -> (i -> a -> b) -> m a
Over (Indexed i) ((,) a) s s a b
l <<%@= :: forall s (m :: * -> *) i a b.
MonadState s m =>
Over (Indexed i) ((,) a) s s a b -> (i -> a -> b) -> m a
<<%@= i -> a -> b
f = forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
State.state (Over (Indexed i) ((,) a) s s a b
l (forall i a b. (i -> a -> b) -> Indexed i a b
Indexed forall a b. (a -> b) -> a -> b
$ \ i
i a
a -> (a
a, i -> a -> b
f i
i a
a)))
{-# INLINE (<<%@=) #-}
(^#) :: s -> ALens s t a b -> a
s
s ^# :: forall s t a b. s -> ALens s t a b -> a
^# ALens s t a b
l = forall (w :: * -> * -> * -> *) a c t.
IndexedComonadStore w =>
w a c t -> a
ipos (ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s)
{-# INLINE (^#) #-}
storing :: ALens s t a b -> b -> s -> t
storing :: forall s t a b. ALens s t a b -> b -> s -> t
storing ALens s t a b
l b
b s
s = forall (w :: * -> * -> * -> *) c a t.
IndexedComonadStore w =>
c -> w a c t -> t
ipeek b
b (ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s)
{-# INLINE storing #-}
(#~) :: ALens s t a b -> b -> s -> t
#~ :: forall s t a b. ALens s t a b -> b -> s -> t
(#~) ALens s t a b
l b
b s
s = forall (w :: * -> * -> * -> *) c a t.
IndexedComonadStore w =>
c -> w a c t -> t
ipeek b
b (ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s)
{-# INLINE (#~) #-}
(#%~) :: ALens s t a b -> (a -> b) -> s -> t
#%~ :: forall s t a b. ALens s t a b -> (a -> b) -> s -> t
(#%~) ALens s t a b
l a -> b
f s
s = forall (w :: * -> * -> * -> *) a c t.
IndexedComonadStore w =>
(a -> c) -> w a c t -> t
ipeeks a -> b
f (ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s)
{-# INLINE (#%~) #-}
(#%%~) :: Functor f => ALens s t a b -> (a -> f b) -> s -> f t
#%%~ :: forall (f :: * -> *) s t a b.
Functor f =>
ALens s t a b -> (a -> f b) -> s -> f t
(#%%~) ALens s t a b
l a -> f b
f s
s = forall (p :: * -> * -> *) a b t.
Pretext p a b t
-> forall (f :: * -> *). Functor f => p a (f b) -> f t
runPretext (ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s) a -> f b
f
{-# INLINE (#%%~) #-}
(#=) :: MonadState s m => ALens s s a b -> b -> m ()
ALens s s a b
l #= :: forall s (m :: * -> *) a b.
MonadState s m =>
ALens s s a b -> b -> m ()
#= b
f = forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (ALens s s a b
l forall s t a b. ALens s t a b -> b -> s -> t
#~ b
f)
{-# INLINE (#=) #-}
(#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m ()
ALens s s a b
l #%= :: forall s (m :: * -> *) a b.
MonadState s m =>
ALens s s a b -> (a -> b) -> m ()
#%= a -> b
f = forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (ALens s s a b
l forall s t a b. ALens s t a b -> (a -> b) -> s -> t
#%~ a -> b
f)
{-# INLINE (#%=) #-}
(<#%~) :: ALens s t a b -> (a -> b) -> s -> (b, t)
ALens s t a b
l <#%~ :: forall s t a b. ALens s t a b -> (a -> b) -> s -> (b, t)
<#%~ a -> b
f = \s
s -> forall (p :: * -> * -> *) a b t.
Pretext p a b t
-> forall (f :: * -> *). Functor f => p a (f b) -> f t
runPretext (ALens s t a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s) forall a b. (a -> b) -> a -> b
$ \a
a -> let b :: b
b = a -> b
f a
a in (b
b, b
b)
{-# INLINE (<#%~) #-}
(<#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m b
ALens s s a b
l <#%= :: forall s (m :: * -> *) a b.
MonadState s m =>
ALens s s a b -> (a -> b) -> m b
<#%= a -> b
f = ALens s s a b
l forall s (m :: * -> *) a b r.
MonadState s m =>
ALens s s a b -> (a -> (r, b)) -> m r
#%%= \a
a -> let b :: b
b = a -> b
f a
a in (b
b, b
b)
{-# INLINE (<#%=) #-}
(#%%=) :: MonadState s m => ALens s s a b -> (a -> (r, b)) -> m r
ALens s s a b
l #%%= :: forall s (m :: * -> *) a b r.
MonadState s m =>
ALens s s a b -> (a -> (r, b)) -> m r
#%%= a -> (r, b)
f = forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
State.state forall a b. (a -> b) -> a -> b
$ \s
s -> forall (p :: * -> * -> *) a b t.
Pretext p a b t
-> forall (f :: * -> *). Functor f => p a (f b) -> f t
runPretext (ALens s s a b
l forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell s
s) a -> (r, b)
f
{-# INLINE (#%%=) #-}
(<#~) :: ALens s t a b -> b -> s -> (b, t)
ALens s t a b
l <#~ :: forall s t a b. ALens s t a b -> b -> s -> (b, t)
<#~ b
b = \s
s -> (b
b, forall s t a b. ALens s t a b -> b -> s -> t
storing ALens s t a b
l b
b s
s)
{-# INLINE (<#~) #-}
(<#=) :: MonadState s m => ALens s s a b -> b -> m b
ALens s s a b
l <#= :: forall s (m :: * -> *) a b.
MonadState s m =>
ALens s s a b -> b -> m b
<#= b
b = do
ALens s s a b
l forall s (m :: * -> *) a b.
MonadState s m =>
ALens s s a b -> b -> m ()
#= b
b
forall (m :: * -> *) a. Monad m => a -> m a
return b
b
{-# INLINE (<#=) #-}
devoid :: Over p f Void Void a b
devoid :: forall {k} (p :: k -> * -> *) (f :: * -> *) (a :: k) b.
Over p f Void Void a b
devoid p a (f b)
_ = forall a. Void -> a
absurd
{-# INLINE devoid #-}
united :: Lens' a ()
united :: forall a. Lens' a ()
united () -> f ()
f a
v = () -> f ()
f () forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \ () -> a
v
{-# INLINE united #-}
data First1 f a = First1 (f a) a
instance (Functor f) => Functor (First1 f) where
fmap :: forall a b. (a -> b) -> First1 f a -> First1 f b
fmap a -> b
f (First1 f a
fa a
a) = forall (f :: * -> *) a. f a -> a -> First1 f a
First1 (a -> b
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a
fa) (a -> b
f a
a)
{-# INLINE fmap #-}
instance (Functor f) => Apply (First1 f) where
First1 f (a -> b)
ff a -> b
f <.> :: forall a b. First1 f (a -> b) -> First1 f a -> First1 f b
<.> First1 f a
_ a
x = forall (f :: * -> *) a. f a -> a -> First1 f a
First1 ((forall a b. (a -> b) -> a -> b
$ a
x) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (a -> b)
ff) (a -> b
f a
x)
{-# INLINE (<.>) #-}
getFirst1 :: First1 f a -> f a
getFirst1 :: forall (f :: * -> *) a. First1 f a -> f a
getFirst1 (First1 f a
fa a
_) = f a
fa
{-# INLINE getFirst1 #-}
head1 :: (Traversable1 t) => Lens' (t a) a
head1 :: forall (t :: * -> *) a. Traversable1 t => Lens' (t a) a
head1 a -> f a
f = forall (f :: * -> *) a. First1 f a -> f a
getFirst1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 t, Apply f) =>
(a -> f b) -> t a -> f (t b)
traverse1 (\a
a -> forall (f :: * -> *) a. f a -> a -> First1 f a
First1 (a -> f a
f a
a) a
a)
{-# INLINE head1 #-}
last1 :: (Traversable1 t) => Lens' (t a) a
last1 :: forall (t :: * -> *) a. Traversable1 t => Lens' (t a) a
last1 a -> f a
f = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {k} (f :: k -> *) (a :: k). Reverse f a -> f a
getReverse forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Traversable1 t => Lens' (t a) a
head1 a -> f a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (f :: k -> *) (a :: k). f a -> Reverse f a
Reverse
{-# INLINE last1 #-}
fusing :: Functor f => LensLike (Yoneda f) s t a b -> LensLike f s t a b
fusing :: forall (f :: * -> *) s t a b.
Functor f =>
LensLike (Yoneda f) s t a b -> LensLike f s t a b
fusing LensLike (Yoneda f) s t a b
t = \a -> f b
f -> forall (f :: * -> *) a. Yoneda f a -> f a
lowerYoneda forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike (Yoneda f) s t a b
t (forall (f :: * -> *) a. Functor f => f a -> Yoneda f a
liftYoneda forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f b
f)
{-# INLINE fusing #-}