{-# LANGUAGE CPP #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE Trustworthy #-}
#include "lens-common.h"
{-# OPTIONS_GHC -Wno-orphans #-}
module Control.Lens.Fold
(
Fold
, IndexedFold
, (^..)
, (^?)
, (^?!)
, pre, ipre
, preview, previews, ipreview, ipreviews
, preuse, preuses, ipreuse, ipreuses
, has, hasn't
, folding, ifolding
, foldring, ifoldring
, folded
, folded64
, unfolded
, iterated
, filtered
, filteredBy
, backwards
, repeated
, replicated
, cycled
, takingWhile
, droppingWhile
, worded, lined
, foldMapOf, foldOf
, foldrOf, foldlOf
, toListOf, toNonEmptyOf
, altOf
, anyOf, allOf, noneOf
, andOf, orOf
, productOf, sumOf
, traverseOf_, forOf_, sequenceAOf_
, traverse1Of_, for1Of_, sequence1Of_
, mapMOf_, forMOf_, sequenceOf_
, asumOf, msumOf
, concatMapOf, concatOf
, elemOf, notElemOf
, lengthOf
, nullOf, notNullOf
, firstOf, first1Of, lastOf, last1Of
, maximumOf, maximum1Of, minimumOf, minimum1Of
, maximumByOf, minimumByOf
, findOf
, findMOf
, foldrOf', foldlOf'
, foldr1Of, foldl1Of
, foldr1Of', foldl1Of'
, foldrMOf, foldlMOf
, lookupOf
, (^@..)
, (^@?)
, (^@?!)
, ifoldMapOf
, ifoldrOf
, ifoldlOf
, ianyOf
, iallOf
, inoneOf
, itraverseOf_
, iforOf_
, imapMOf_
, iforMOf_
, iconcatMapOf
, ifindOf
, ifindMOf
, ifoldrOf'
, ifoldlOf'
, ifoldrMOf
, ifoldlMOf
, itoListOf
, elemIndexOf
, elemIndicesOf
, findIndexOf
, findIndicesOf
, ifiltered
, itakingWhile
, idroppingWhile
, Leftmost
, Rightmost
, Traversed
, Sequenced
, foldBy
, foldByOf
, foldMapBy
, foldMapByOf
) where
import Prelude ()
import Control.Applicative.Backwards
import Control.Comonad
import Control.Lens.Getter
import Control.Lens.Internal.Fold
import Control.Lens.Internal.Getter
import Control.Lens.Internal.Indexed
import Control.Lens.Internal.Magma
import Control.Lens.Internal.Prelude
import Control.Lens.Type
import Control.Monad as Monad
import Control.Monad.Reader
import Control.Monad.State
import Data.CallStack
import Data.Functor.Apply hiding ((<.))
import Data.Int (Int64)
import Data.List (intercalate)
import Data.Maybe (fromMaybe)
import Data.Monoid (First (..), All (..), Alt (..), Any (..))
import Data.Reflection
import qualified Data.Semigroup as Semi
infixl 8 ^.., ^?, ^?!, ^@.., ^@?, ^@?!
folding :: Foldable f => (s -> f a) -> Fold s a
folding :: forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
folding s -> f a
sfa a -> f a
agb = f () -> f s
forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom (f () -> f s) -> (s -> f ()) -> s -> f s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> f a -> f ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ a -> f a
agb (f a -> f ()) -> (s -> f a) -> s -> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> f a
sfa
{-# INLINE folding #-}
ifolding :: (Foldable f, Indexable i p, Contravariant g, Applicative g) => (s -> f (i, a)) -> Over p g s t a b
ifolding :: 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 s -> f (i, a)
sfa p a (g b)
f = g () -> g t
forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom (g () -> g t) -> (s -> g ()) -> s -> g t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((i, a) -> g Any) -> f (i, a) -> g ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ (g b -> g Any
forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom (g b -> g Any) -> ((i, a) -> g b) -> (i, a) -> g Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (i -> a -> g b) -> (i, a) -> g b
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (p a (g b) -> i -> a -> g b
forall a b. p a b -> i -> a -> b
forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p a (g b)
f)) (f (i, a) -> g ()) -> (s -> f (i, a)) -> s -> g ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> f (i, a)
sfa
{-# INLINE ifolding #-}
foldring :: (Contravariant f, Applicative f) => ((a -> f a -> f a) -> f a -> s -> f a) -> LensLike f s t a b
foldring :: forall (f :: * -> *) a s t b.
(Contravariant f, Applicative f) =>
((a -> f a -> f a) -> f a -> s -> f a) -> LensLike f s t a b
foldring (a -> f a -> f a) -> f a -> s -> f a
fr a -> f b
f = f a -> f t
forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom (f a -> f t) -> (s -> f a) -> s -> f t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a -> f a) -> f a -> s -> f a
fr (\a
a f a
fa -> a -> f b
f a
a f b -> f a -> f a
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> f a
fa) f a
forall (f :: * -> *) a. (Contravariant f, Applicative f) => f a
noEffect
{-# INLINE foldring #-}
ifoldring :: (Indexable i p, Contravariant f, Applicative f) => ((i -> a -> f a -> f a) -> f a -> s -> f a) -> Over p f s t a b
ifoldring :: forall i (p :: * -> * -> *) (f :: * -> *) a s t b.
(Indexable i p, Contravariant f, Applicative f) =>
((i -> a -> f a -> f a) -> f a -> s -> f a) -> Over p f s t a b
ifoldring (i -> a -> f a -> f a) -> f a -> s -> f a
ifr p a (f b)
f = f a -> f t
forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom (f a -> f t) -> (s -> f a) -> s -> f t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (i -> a -> f a -> f a) -> f a -> s -> f a
ifr (\i
i a
a f a
fa -> p a (f b) -> i -> a -> f b
forall a b. p a b -> i -> a -> b
forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p a (f b)
f i
i a
a f b -> f a -> f a
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> f a
fa) f a
forall (f :: * -> *) a. (Contravariant f, Applicative f) => f a
noEffect
{-# INLINE ifoldring #-}
folded :: Foldable f => IndexedFold Int (f a) a
folded :: forall (f :: * -> *) a. Foldable f => IndexedFold Int (f a) a
folded = ((p ~ (->)) => (a -> f a) -> f a -> f (f a))
-> (p a (f a) -> f a -> f (f a)) -> p a (f a) -> f a -> f (f a)
forall (p :: * -> * -> *) (q :: * -> * -> *) a b r.
Conjoined p =>
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
forall (q :: * -> * -> *) a b r.
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
conjoined (((a -> f a -> f a) -> f a -> f a -> f a)
-> (a -> f a) -> f a -> f (f a)
forall (f :: * -> *) a s t b.
(Contravariant f, Applicative f) =>
((a -> f a -> f a) -> f a -> s -> f a) -> LensLike f s t a b
foldring (a -> f a -> f a) -> f a -> f a -> f a
forall a b. (a -> b -> b) -> b -> f a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr) (((Int -> a -> f a -> f a) -> f a -> f a -> f a)
-> p a (f a) -> f a -> f (f a)
forall i (p :: * -> * -> *) (f :: * -> *) a s t b.
(Indexable i p, Contravariant f, Applicative f) =>
((i -> a -> f a -> f a) -> f a -> s -> f a) -> Over p f s t a b
ifoldring (Int -> a -> f a -> f a) -> f a -> f a -> f a
forall (f :: * -> *) a b.
Foldable f =>
(Int -> a -> b -> b) -> b -> f a -> b
ifoldr)
{-# INLINE folded #-}
ifoldr :: Foldable f => (Int -> a -> b -> b) -> b -> f a -> b
ifoldr :: forall (f :: * -> *) a b.
Foldable f =>
(Int -> a -> b -> b) -> b -> f a -> b
ifoldr Int -> a -> b -> b
f b
z f a
xs = (a -> (Int -> b) -> Int -> b) -> (Int -> b) -> f a -> Int -> b
forall a b. (a -> b -> b) -> b -> f a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\ a
x Int -> b
g Int
i -> Int
i Int -> b -> b
forall a b. a -> b -> b
`seq` Int -> a -> b -> b
f Int
i a
x (Int -> b
g (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1))) (b -> Int -> b
forall a b. a -> b -> a
const b
z) f a
xs Int
0
{-# INLINE ifoldr #-}
folded64 :: Foldable f => IndexedFold Int64 (f a) a
folded64 :: forall (f :: * -> *) a. Foldable f => IndexedFold Int64 (f a) a
folded64 = ((p ~ (->)) => (a -> f a) -> f a -> f (f a))
-> (p a (f a) -> f a -> f (f a)) -> p a (f a) -> f a -> f (f a)
forall (p :: * -> * -> *) (q :: * -> * -> *) a b r.
Conjoined p =>
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
forall (q :: * -> * -> *) a b r.
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
conjoined (((a -> f a -> f a) -> f a -> f a -> f a)
-> (a -> f a) -> f a -> f (f a)
forall (f :: * -> *) a s t b.
(Contravariant f, Applicative f) =>
((a -> f a -> f a) -> f a -> s -> f a) -> LensLike f s t a b
foldring (a -> f a -> f a) -> f a -> f a -> f a
forall a b. (a -> b -> b) -> b -> f a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr) (((Int64 -> a -> f a -> f a) -> f a -> f a -> f a)
-> p a (f a) -> f a -> f (f a)
forall i (p :: * -> * -> *) (f :: * -> *) a s t b.
(Indexable i p, Contravariant f, Applicative f) =>
((i -> a -> f a -> f a) -> f a -> s -> f a) -> Over p f s t a b
ifoldring (Int64 -> a -> f a -> f a) -> f a -> f a -> f a
forall (f :: * -> *) a b.
Foldable f =>
(Int64 -> a -> b -> b) -> b -> f a -> b
ifoldr64)
{-# INLINE folded64 #-}
ifoldr64 :: Foldable f => (Int64 -> a -> b -> b) -> b -> f a -> b
ifoldr64 :: forall (f :: * -> *) a b.
Foldable f =>
(Int64 -> a -> b -> b) -> b -> f a -> b
ifoldr64 Int64 -> a -> b -> b
f b
z f a
xs = (a -> (Int64 -> b) -> Int64 -> b)
-> (Int64 -> b) -> f a -> Int64 -> b
forall a b. (a -> b -> b) -> b -> f a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\ a
x Int64 -> b
g Int64
i -> Int64
i Int64 -> b -> b
forall a b. a -> b -> b
`seq` Int64 -> a -> b -> b
f Int64
i a
x (Int64 -> b
g (Int64
iInt64 -> Int64 -> Int64
forall a. Num a => a -> a -> a
+Int64
1))) (b -> Int64 -> b
forall a b. a -> b -> a
const b
z) f a
xs Int64
0
{-# INLINE ifoldr64 #-}
repeated :: Apply f => LensLike' f a a
repeated :: forall (f :: * -> *) a. Apply f => LensLike' f a a
repeated a -> f a
f a
a = f a
forall {b}. f b
as where as :: f b
as = a -> f a
f a
a f a -> f b -> f b
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Apply f => f a -> f b -> f b
.> f b
as
{-# INLINE repeated #-}
replicated :: Int -> Fold a a
replicated :: forall a. Int -> Fold a a
replicated Int
n0 a -> f a
f a
a = Int -> f a
forall {t} {a}. (Eq t, Num t) => t -> f a
go Int
n0 where
m :: f a
m = a -> f a
f a
a
go :: t -> f a
go t
0 = f a
forall (f :: * -> *) a. (Contravariant f, Applicative f) => f a
noEffect
go t
n = f a
m f a -> f a -> f a
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> t -> f a
go (t
n t -> t -> t
forall a. Num a => a -> a -> a
- t
1)
{-# INLINE replicated #-}
cycled :: Apply f => LensLike f s t a b -> LensLike f s t a b
cycled :: forall (f :: * -> *) s t a b.
Apply f =>
LensLike f s t a b -> LensLike f s t a b
cycled LensLike f s t a b
l a -> f b
f s
a = f t
forall {b}. f b
as where as :: f b
as = LensLike f s t a b
l a -> f b
f s
a f t -> f b -> f b
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Apply f => f a -> f b -> f b
.> f b
as
{-# INLINE cycled #-}
unfolded :: (b -> Maybe (a, b)) -> Fold b a
unfolded :: forall b a. (b -> Maybe (a, b)) -> Fold b a
unfolded b -> Maybe (a, b)
f a -> f a
g = b -> f b
forall {b}. b -> f b
go where
go :: b -> f b
go b
b = case b -> Maybe (a, b)
f b
b of
Just (a
a, b
b') -> a -> f a
g a
a f a -> f b -> f b
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> b -> f b
go b
b'
Maybe (a, b)
Nothing -> f b
forall (f :: * -> *) a. (Contravariant f, Applicative f) => f a
noEffect
{-# INLINE unfolded #-}
iterated :: Apply f => (a -> a) -> LensLike' f a a
iterated :: forall (f :: * -> *) a. Apply f => (a -> a) -> LensLike' f a a
iterated a -> a
f a -> f a
g = a -> f a
forall {b}. a -> f b
go where
go :: a -> f b
go a
a = a -> f a
g a
a f a -> f b -> f b
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Apply f => f a -> f b -> f b
.> a -> f b
go (a -> a
f a
a)
{-# INLINE iterated #-}
filtered :: (Choice p, Applicative f) => (a -> Bool) -> Optic' p f a a
filtered :: forall (p :: * -> * -> *) (f :: * -> *) a.
(Choice p, Applicative f) =>
(a -> Bool) -> Optic' p f a a
filtered a -> Bool
p = (a -> Either a a)
-> (Either a (f a) -> f a)
-> p (Either a a) (Either a (f a))
-> p a (f a)
forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (\a
x -> if a -> Bool
p a
x then a -> Either a a
forall a b. b -> Either a b
Right a
x else a -> Either a a
forall a b. a -> Either a b
Left a
x) ((a -> f a) -> (f a -> f a) -> Either a (f a) -> f a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either a -> f a
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure f a -> f a
forall a. a -> a
id) (p (Either a a) (Either a (f a)) -> p a (f a))
-> (p a (f a) -> p (Either a a) (Either a (f a)))
-> p a (f a)
-> p a (f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p a (f a) -> p (Either a a) (Either a (f a))
forall a b c. p a b -> p (Either c a) (Either c b)
forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right'
{-# INLINE filtered #-}
filteredBy :: (Indexable i p, Applicative f) => Getting (First i) a i -> p a (f a) -> a -> f a
filteredBy :: forall i (p :: * -> * -> *) (f :: * -> *) a.
(Indexable i p, Applicative f) =>
Getting (First i) a i -> p a (f a) -> a -> f a
filteredBy Getting (First i) a i
p p a (f a)
f a
val = case a
val a -> Getting (First i) a i -> Maybe i
forall s a. s -> Getting (First a) s a -> Maybe a
^? Getting (First i) a i
p of
Maybe i
Nothing -> a -> f a
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
val
Just i
witness -> p a (f a) -> i -> a -> f a
forall a b. p a b -> i -> a -> b
forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p a (f a)
f i
witness a
val
takingWhile :: (Conjoined p, Applicative f) => (a -> Bool) -> Over p (TakingWhile p f a a) s t a a -> Over p f s t a a
takingWhile :: forall (p :: * -> * -> *) (f :: * -> *) a s t.
(Conjoined p, Applicative f) =>
(a -> Bool)
-> Over p (TakingWhile p f a a) s t a a -> Over p f s t a a
takingWhile a -> Bool
p Over p (TakingWhile p f a a) s t a a
l p a (f a)
pafb = (Magma () t a a -> t) -> f (Magma () t a a) -> f t
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Magma () t a a -> t
forall i t a. Magma i t a a -> t
runMagma (f (Magma () t a a) -> f t)
-> (s -> f (Magma () t a a)) -> s -> f t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Corep p a -> f a)
-> Magma () t a (Corep p a) -> f (Magma () t a a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Magma () t a a -> f (Magma () t a b)
traverse (p a (f a) -> Corep p a -> f a
forall a b. p a b -> Corep p a -> b
forall (p :: * -> * -> *) (f :: * -> *) a b.
Cosieve p f =>
p a b -> f a -> b
cosieve p a (f a)
pafb) (Magma () t a (Corep p a) -> f (Magma () t a a))
-> (s -> Magma () t a (Corep p a)) -> s -> f (Magma () t a a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TakingWhile p f a a t -> Magma () t a (Corep p a)
forall (p :: * -> * -> *) (f :: * -> *) a b t.
TakingWhile p f a b t -> Magma () t b (Corep p a)
runTakingWhile (TakingWhile p f a a t -> Magma () t a (Corep p a))
-> (s -> TakingWhile p f a a t) -> s -> Magma () t a (Corep p a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Over p (TakingWhile p f a a) s t a a
l p a (TakingWhile p f a a a)
forall {g :: * -> *}. p a (TakingWhile p g a a a)
flag where
flag :: p a (TakingWhile p g a a a)
flag = (Corep p a -> TakingWhile p g a a a) -> p a (TakingWhile p g a a a)
forall d c. (Corep p d -> c) -> p d c
forall (p :: * -> * -> *) d c.
Corepresentable p =>
(Corep p d -> c) -> p d c
cotabulate ((Corep p a -> TakingWhile p g a a a)
-> p a (TakingWhile p g a a a))
-> (Corep p a -> TakingWhile p g a a a)
-> p a (TakingWhile p g a a a)
forall a b. (a -> b) -> a -> b
$ \Corep p a
wa -> let a :: a
a = Corep p a -> a
forall a. Corep p a -> a
forall (w :: * -> *) a. Comonad w => w a -> a
extract Corep p a
wa; r :: Bool
r = a -> Bool
p a
a in Bool
-> a -> (Bool -> Magma () a a (Corep p a)) -> TakingWhile p g a a a
forall (p :: * -> * -> *) (g :: * -> *) a b t.
Bool
-> t -> (Bool -> Magma () t b (Corep p a)) -> TakingWhile p g a b t
TakingWhile Bool
r a
a ((Bool -> Magma () a a (Corep p a)) -> TakingWhile p g a a a)
-> (Bool -> Magma () a a (Corep p a)) -> TakingWhile p g a a a
forall a b. (a -> b) -> a -> b
$ \Bool
pr ->
if Bool
pr Bool -> Bool -> Bool
&& Bool
r then () -> Corep p a -> Magma () a a (Corep p a)
forall i a t. i -> a -> Magma i t t a
Magma () Corep p a
wa else a -> Magma () a a (Corep p a)
forall t i b a. t -> Magma i t b a
MagmaPure a
a
{-# INLINE takingWhile #-}
droppingWhile :: (Conjoined p, Profunctor q, Applicative f)
=> (a -> Bool)
-> Optical p q (Compose (State Bool) f) s t a a
-> Optical p q f s t a a
droppingWhile :: forall (p :: * -> * -> *) (q :: * -> * -> *) (f :: * -> *) a s t.
(Conjoined p, Profunctor q, Applicative f) =>
(a -> Bool)
-> Optical p q (Compose (State Bool) f) s t a a
-> Optical p q f s t a a
droppingWhile a -> Bool
p Optical p q (Compose (State Bool) f) s t a a
l p a (f a)
f = ((State Bool (f t) -> Bool -> f t)
-> Bool -> State Bool (f t) -> f t
forall a b c. (a -> b -> c) -> b -> a -> c
flip State Bool (f t) -> Bool -> f t
forall s a. State s a -> s -> a
evalState Bool
True (State Bool (f t) -> f t)
-> (Compose (State Bool) f t -> State Bool (f t))
-> Compose (State Bool) f t
-> f t
forall a b c (q :: * -> * -> *).
Coercible b a =>
(b -> c) -> q a b -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# Compose (State Bool) f t -> State Bool (f t)
forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose) (Compose (State Bool) f t -> f t)
-> q s (Compose (State Bool) f t) -> q s (f t)
forall b c a. (b -> c) -> q a b -> q a c
forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
`rmap` Optical p q (Compose (State Bool) f) s t a a
l p a (Compose (State Bool) f a)
g where
g :: p a (Compose (State Bool) f a)
g = (Corep p a -> Compose (State Bool) f a)
-> p a (Compose (State Bool) f a)
forall d c. (Corep p d -> c) -> p d c
forall (p :: * -> * -> *) d c.
Corepresentable p =>
(Corep p d -> c) -> p d c
cotabulate ((Corep p a -> Compose (State Bool) f a)
-> p a (Compose (State Bool) f a))
-> (Corep p a -> Compose (State Bool) f a)
-> p a (Compose (State Bool) f a)
forall a b. (a -> b) -> a -> b
$ \Corep p a
wa -> State Bool (f a) -> Compose (State Bool) f a
forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (State Bool (f a) -> Compose (State Bool) f a)
-> State Bool (f a) -> Compose (State Bool) f a
forall a b. (a -> b) -> a -> b
$ (Bool -> (f a, Bool)) -> State Bool (f a)
forall a. (Bool -> (a, Bool)) -> State Bool a
forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
state ((Bool -> (f a, Bool)) -> State Bool (f a))
-> (Bool -> (f a, Bool)) -> State Bool (f a)
forall a b. (a -> b) -> a -> b
$ \Bool
b -> let
a :: a
a = Corep p a -> a
forall a. Corep p a -> a
forall (w :: * -> *) a. Comonad w => w a -> a
extract Corep p a
wa
b' :: Bool
b' = Bool
b Bool -> Bool -> Bool
&& a -> Bool
p a
a
in (if Bool
b' then a -> f a
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a else p a (f a) -> Corep p a -> f a
forall a b. p a b -> Corep p a -> b
forall (p :: * -> * -> *) (f :: * -> *) a b.
Cosieve p f =>
p a b -> f a -> b
cosieve p a (f a)
f Corep p a
wa, Bool
b')
{-# INLINE droppingWhile #-}
worded :: Applicative f => IndexedLensLike' Int f String String
worded :: forall (f :: * -> *).
Applicative f =>
IndexedLensLike' Int f String String
worded p String (f String)
f = ([String] -> String) -> f [String] -> f String
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [String] -> String
unwords (f [String] -> f String)
-> (String -> f [String]) -> String -> f String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((p ~ (->)) => (String -> f String) -> [String] -> f [String])
-> (p String (f String) -> [String] -> f [String])
-> p String (f String)
-> [String]
-> f [String]
forall (p :: * -> * -> *) (q :: * -> * -> *) a b r.
Conjoined p =>
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
forall (q :: * -> * -> *) a b r.
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
conjoined (p ~ (->)) => (String -> f String) -> [String] -> f [String]
(String -> f String) -> [String] -> f [String]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((String -> Indexing f String) -> [String] -> Indexing f [String])
-> p String (f String) -> [String] -> f [String]
forall (p :: * -> * -> *) a (f :: * -> *) b s t.
Indexable Int p =>
((a -> Indexing f b) -> s -> Indexing f t) -> p a (f b) -> s -> f t
indexing (String -> Indexing f String) -> [String] -> Indexing f [String]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse) p String (f String)
f ([String] -> f [String])
-> (String -> [String]) -> String -> f [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
words
{-# INLINE worded #-}
lined :: Applicative f => IndexedLensLike' Int f String String
lined :: forall (f :: * -> *).
Applicative f =>
IndexedLensLike' Int f String String
lined p String (f String)
f = ([String] -> String) -> f [String] -> f String
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"\n") (f [String] -> f String)
-> (String -> f [String]) -> String -> f String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((p ~ (->)) => (String -> f String) -> [String] -> f [String])
-> (p String (f String) -> [String] -> f [String])
-> p String (f String)
-> [String]
-> f [String]
forall (p :: * -> * -> *) (q :: * -> * -> *) a b r.
Conjoined p =>
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
forall (q :: * -> * -> *) a b r.
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
conjoined (p ~ (->)) => (String -> f String) -> [String] -> f [String]
(String -> f String) -> [String] -> f [String]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((String -> Indexing f String) -> [String] -> Indexing f [String])
-> p String (f String) -> [String] -> f [String]
forall (p :: * -> * -> *) a (f :: * -> *) b s t.
Indexable Int p =>
((a -> Indexing f b) -> s -> Indexing f t) -> p a (f b) -> s -> f t
indexing (String -> Indexing f String) -> [String] -> Indexing f [String]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse) p String (f String)
f ([String] -> f [String])
-> (String -> [String]) -> String -> f [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
lines
{-# INLINE lined #-}
foldMapOf :: Getting r s a -> (a -> r) -> s -> r
foldMapOf :: forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf = Getting r s a -> (a -> r) -> s -> r
forall a b. Coercible a b => a -> b
coerce
{-# INLINE foldMapOf #-}
foldOf :: Getting a s a -> s -> a
foldOf :: forall a s. Getting a s a -> s -> a
foldOf Getting a s a
l = Const a s -> a
forall {k} a (b :: k). Const a b -> a
getConst (Const a s -> a) -> (s -> Const a s) -> s -> a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting a s a
l a -> Const a a
forall {k} a (b :: k). a -> Const a b
Const
{-# INLINE foldOf #-}
foldrOf :: Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf :: forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo r) s a
l a -> r -> r
f r
z = (Endo r -> r -> r) -> r -> Endo r -> r
forall a b c. (a -> b -> c) -> b -> a -> c
flip Endo r -> r -> r
forall a. Endo a -> a -> a
appEndo r
z (Endo r -> r) -> (s -> Endo r) -> s -> r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Endo r) s a -> (a -> Endo r) -> s -> Endo r
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Endo r) s a
l ((r -> r) -> Endo r
forall a. (a -> a) -> Endo a
Endo ((r -> r) -> Endo r) -> (a -> r -> r) -> a -> Endo r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> r -> r
f)
{-# INLINE foldrOf #-}
foldlOf :: Getting (Dual (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf :: forall r s a.
Getting (Dual (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf Getting (Dual (Endo r)) s a
l r -> a -> r
f r
z = ((Endo r -> r -> r) -> r -> Endo r -> r
forall a b c. (a -> b -> c) -> b -> a -> c
flip Endo r -> r -> r
forall a. Endo a -> a -> a
appEndo r
z (Endo r -> r) -> (Dual (Endo r) -> Endo r) -> Dual (Endo r) -> r
forall a b c (q :: * -> * -> *).
Coercible b a =>
(b -> c) -> q a b -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# Dual (Endo r) -> Endo r
forall a. Dual a -> a
getDual) (Dual (Endo r) -> r) -> (s -> Dual (Endo r)) -> s -> r
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
`rmap` Getting (Dual (Endo r)) s a
-> (a -> Dual (Endo r)) -> s -> Dual (Endo r)
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Dual (Endo r)) s a
l (Endo r -> Dual (Endo r)
forall a. a -> Dual a
Dual (Endo r -> Dual (Endo r)) -> (a -> Endo r) -> a -> Dual (Endo r)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. (r -> r) -> Endo r
forall a. (a -> a) -> Endo a
Endo ((r -> r) -> Endo r) -> (a -> r -> r) -> a -> Endo r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. (r -> a -> r) -> a -> r -> r
forall a b c. (a -> b -> c) -> b -> a -> c
flip r -> a -> r
f)
{-# INLINE foldlOf #-}
toListOf :: Getting (Endo [a]) s a -> s -> [a]
toListOf :: forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Getting (Endo [a]) s a
l = Getting (Endo [a]) s a -> (a -> [a] -> [a]) -> [a] -> s -> [a]
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo [a]) s a
l (:) []
{-# INLINE toListOf #-}
toNonEmptyOf :: Getting (NonEmptyDList a) s a -> s -> NonEmpty a
toNonEmptyOf :: forall a s. Getting (NonEmptyDList a) s a -> s -> NonEmpty a
toNonEmptyOf Getting (NonEmptyDList a) s a
l = (NonEmptyDList a -> [a] -> NonEmpty a)
-> [a] -> NonEmptyDList a -> NonEmpty a
forall a b c. (a -> b -> c) -> b -> a -> c
flip NonEmptyDList a -> [a] -> NonEmpty a
forall a. NonEmptyDList a -> [a] -> NonEmpty a
getNonEmptyDList [] (NonEmptyDList a -> NonEmpty a)
-> (s -> NonEmptyDList a) -> s -> NonEmpty a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (NonEmptyDList a) s a
-> (a -> NonEmptyDList a) -> s -> NonEmptyDList a
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (NonEmptyDList a) s a
l (([a] -> NonEmpty a) -> NonEmptyDList a
forall a. ([a] -> NonEmpty a) -> NonEmptyDList a
NonEmptyDList (([a] -> NonEmpty a) -> NonEmptyDList a)
-> (a -> [a] -> NonEmpty a) -> a -> NonEmptyDList a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> [a] -> NonEmpty a
forall a. a -> [a] -> NonEmpty a
(:|))
altOf :: Applicative f => Getting (Alt f a) s a -> s -> f a
altOf :: forall (f :: * -> *) a s.
Applicative f =>
Getting (Alt f a) s a -> s -> f a
altOf Getting (Alt f a) s a
l = Alt f a -> f a
forall {k} (f :: k -> *) (a :: k). Alt f a -> f a
getAlt (Alt f a -> f a) -> (s -> Alt f a) -> s -> f a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting (Alt f a) s a -> (a -> Alt f a) -> s -> Alt f a
forall s (m :: * -> *) r a.
MonadReader s m =>
LensLike' (Const r) s a -> (a -> r) -> m r
views Getting (Alt f a) s a
l (f a -> Alt f a
forall {k} (f :: k -> *) (a :: k). f a -> Alt f a
Alt (f a -> Alt f a) -> (a -> f a) -> a -> Alt f a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> f a
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure)
{-# INLINE altOf #-}
(^..) :: s -> Getting (Endo [a]) s a -> [a]
s
s ^.. :: forall s a. s -> Getting (Endo [a]) s a -> [a]
^.. Getting (Endo [a]) s a
l = Getting (Endo [a]) s a -> s -> [a]
forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Getting (Endo [a]) s a
l s
s
{-# INLINE (^..) #-}
andOf :: Getting All s Bool -> s -> Bool
andOf :: forall s. Getting All s Bool -> s -> Bool
andOf Getting All s Bool
l = All -> Bool
getAll (All -> Bool) -> (s -> All) -> s -> Bool
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting All s Bool -> (Bool -> All) -> s -> All
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting All s Bool
l Bool -> All
All
{-# INLINE andOf #-}
orOf :: Getting Any s Bool -> s -> Bool
orOf :: forall s. Getting Any s Bool -> s -> Bool
orOf Getting Any s Bool
l = Any -> Bool
getAny (Any -> Bool) -> (s -> Any) -> s -> Bool
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting Any s Bool -> (Bool -> Any) -> s -> Any
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting Any s Bool
l Bool -> Any
Any
{-# INLINE orOf #-}
anyOf :: Getting Any s a -> (a -> Bool) -> s -> Bool
anyOf :: forall s a. Getting Any s a -> (a -> Bool) -> s -> Bool
anyOf Getting Any s a
l a -> Bool
f = Any -> Bool
getAny (Any -> Bool) -> (s -> Any) -> s -> Bool
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting Any s a -> (a -> Any) -> s -> Any
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting Any s a
l (Bool -> Any
Any (Bool -> Any) -> (a -> Bool) -> a -> Any
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> Bool
f)
{-# INLINE anyOf #-}
allOf :: Getting All s a -> (a -> Bool) -> s -> Bool
allOf :: forall s a. Getting All s a -> (a -> Bool) -> s -> Bool
allOf Getting All s a
l a -> Bool
f = All -> Bool
getAll (All -> Bool) -> (s -> All) -> s -> Bool
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting All s a -> (a -> All) -> s -> All
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting All s a
l (Bool -> All
All (Bool -> All) -> (a -> Bool) -> a -> All
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> Bool
f)
{-# INLINE allOf #-}
noneOf :: Getting Any s a -> (a -> Bool) -> s -> Bool
noneOf :: forall s a. Getting Any s a -> (a -> Bool) -> s -> Bool
noneOf Getting Any s a
l a -> Bool
f = Bool -> Bool
not (Bool -> Bool) -> (s -> Bool) -> s -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting Any s a -> (a -> Bool) -> s -> Bool
forall s a. Getting Any s a -> (a -> Bool) -> s -> Bool
anyOf Getting Any s a
l a -> Bool
f
{-# INLINE noneOf #-}
productOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a
productOf :: forall a s. Num a => Getting (Endo (Endo a)) s a -> s -> a
productOf Getting (Endo (Endo a)) s a
l = Getting (Endo (Endo a)) s a -> (a -> a -> a) -> a -> s -> a
forall r s a.
Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' Getting (Endo (Endo a)) s a
l a -> a -> a
forall a. Num a => a -> a -> a
(*) a
1
{-# INLINE productOf #-}
sumOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a
sumOf :: forall a s. Num a => Getting (Endo (Endo a)) s a -> s -> a
sumOf Getting (Endo (Endo a)) s a
l = Getting (Endo (Endo a)) s a -> (a -> a -> a) -> a -> s -> a
forall r s a.
Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' Getting (Endo (Endo a)) s a
l a -> a -> a
forall a. Num a => a -> a -> a
(+) a
0
{-# INLINE sumOf #-}
traverseOf_ :: Functor f => Getting (Traversed r f) s a -> (a -> f r) -> s -> f ()
traverseOf_ :: forall (f :: * -> *) r s a.
Functor f =>
Getting (Traversed r f) s a -> (a -> f r) -> s -> f ()
traverseOf_ Getting (Traversed r f) s a
l a -> f r
f = f r -> f ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (f r -> f ()) -> (s -> f r) -> s -> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Traversed r f -> f r
forall a (f :: * -> *). Traversed a f -> f a
getTraversed (Traversed r f -> f r) -> (s -> Traversed r f) -> s -> f r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting (Traversed r f) s a
-> (a -> Traversed r f) -> s -> Traversed r f
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Traversed r f) s a
l (f r -> Traversed r f
forall a (f :: * -> *). f a -> Traversed a f
Traversed (f r -> Traversed r f) -> (a -> f r) -> a -> Traversed r f
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> f r
f)
{-# INLINE traverseOf_ #-}
forOf_ :: Functor f => Getting (Traversed r f) s a -> s -> (a -> f r) -> f ()
forOf_ :: forall (f :: * -> *) r s a.
Functor f =>
Getting (Traversed r f) s a -> s -> (a -> f r) -> f ()
forOf_ = ((a -> f r) -> s -> f ()) -> s -> (a -> f r) -> f ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((a -> f r) -> s -> f ()) -> s -> (a -> f r) -> f ())
-> (Getting (Traversed r f) s a -> (a -> f r) -> s -> f ())
-> Getting (Traversed r f) s a
-> s
-> (a -> f r)
-> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Traversed r f) s a -> (a -> f r) -> s -> f ()
forall (f :: * -> *) r s a.
Functor f =>
Getting (Traversed r f) s a -> (a -> f r) -> s -> f ()
traverseOf_
{-# INLINE forOf_ #-}
sequenceAOf_ :: Functor f => Getting (Traversed a f) s (f a) -> s -> f ()
sequenceAOf_ :: forall (f :: * -> *) a s.
Functor f =>
Getting (Traversed a f) s (f a) -> s -> f ()
sequenceAOf_ Getting (Traversed a f) s (f a)
l = f a -> f ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (f a -> f ()) -> (s -> f a) -> s -> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Traversed a f -> f a
forall a (f :: * -> *). Traversed a f -> f a
getTraversed (Traversed a f -> f a) -> (s -> Traversed a f) -> s -> f a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting (Traversed a f) s (f a)
-> (f a -> Traversed a f) -> s -> Traversed a f
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Traversed a f) s (f a)
l f a -> Traversed a f
forall a (f :: * -> *). f a -> Traversed a f
Traversed
{-# INLINE sequenceAOf_ #-}
traverse1Of_ :: Functor f => Getting (TraversedF r f) s a -> (a -> f r) -> s -> f ()
traverse1Of_ :: forall (f :: * -> *) r s a.
Functor f =>
Getting (TraversedF r f) s a -> (a -> f r) -> s -> f ()
traverse1Of_ Getting (TraversedF r f) s a
l a -> f r
f = f r -> f ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (f r -> f ()) -> (s -> f r) -> s -> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TraversedF r f -> f r
forall a (f :: * -> *). TraversedF a f -> f a
getTraversedF (TraversedF r f -> f r) -> (s -> TraversedF r f) -> s -> f r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting (TraversedF r f) s a
-> (a -> TraversedF r f) -> s -> TraversedF r f
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (TraversedF r f) s a
l (f r -> TraversedF r f
forall a (f :: * -> *). f a -> TraversedF a f
TraversedF (f r -> TraversedF r f) -> (a -> f r) -> a -> TraversedF r f
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> f r
f)
{-# INLINE traverse1Of_ #-}
for1Of_ :: Functor f => Getting (TraversedF r f) s a -> s -> (a -> f r) -> f ()
for1Of_ :: forall (f :: * -> *) r s a.
Functor f =>
Getting (TraversedF r f) s a -> s -> (a -> f r) -> f ()
for1Of_ = ((a -> f r) -> s -> f ()) -> s -> (a -> f r) -> f ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((a -> f r) -> s -> f ()) -> s -> (a -> f r) -> f ())
-> (Getting (TraversedF r f) s a -> (a -> f r) -> s -> f ())
-> Getting (TraversedF r f) s a
-> s
-> (a -> f r)
-> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (TraversedF r f) s a -> (a -> f r) -> s -> f ()
forall (f :: * -> *) r s a.
Functor f =>
Getting (TraversedF r f) s a -> (a -> f r) -> s -> f ()
traverse1Of_
{-# INLINE for1Of_ #-}
sequence1Of_ :: Functor f => Getting (TraversedF a f) s (f a) -> s -> f ()
sequence1Of_ :: forall (f :: * -> *) a s.
Functor f =>
Getting (TraversedF a f) s (f a) -> s -> f ()
sequence1Of_ Getting (TraversedF a f) s (f a)
l = f a -> f ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (f a -> f ()) -> (s -> f a) -> s -> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TraversedF a f -> f a
forall a (f :: * -> *). TraversedF a f -> f a
getTraversedF (TraversedF a f -> f a) -> (s -> TraversedF a f) -> s -> f a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting (TraversedF a f) s (f a)
-> (f a -> TraversedF a f) -> s -> TraversedF a f
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (TraversedF a f) s (f a)
l f a -> TraversedF a f
forall a (f :: * -> *). f a -> TraversedF a f
TraversedF
{-# INLINE sequence1Of_ #-}
mapMOf_ :: Monad m => Getting (Sequenced r m) s a -> (a -> m r) -> s -> m ()
mapMOf_ :: forall (m :: * -> *) r s a.
Monad m =>
Getting (Sequenced r m) s a -> (a -> m r) -> s -> m ()
mapMOf_ Getting (Sequenced r m) s a
l a -> m r
f = (r -> ()) -> m r -> m ()
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM r -> ()
forall a. a -> ()
skip (m r -> m ()) -> (s -> m r) -> s -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sequenced r m -> m r
forall a (m :: * -> *). Sequenced a m -> m a
getSequenced (Sequenced r m -> m r) -> (s -> Sequenced r m) -> s -> m r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting (Sequenced r m) s a
-> (a -> Sequenced r m) -> s -> Sequenced r m
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Sequenced r m) s a
l (m r -> Sequenced r m
forall a (m :: * -> *). m a -> Sequenced a m
Sequenced (m r -> Sequenced r m) -> (a -> m r) -> a -> Sequenced r m
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> m r
f)
{-# INLINE mapMOf_ #-}
forMOf_ :: Monad m => Getting (Sequenced r m) s a -> s -> (a -> m r) -> m ()
forMOf_ :: forall (m :: * -> *) r s a.
Monad m =>
Getting (Sequenced r m) s a -> s -> (a -> m r) -> m ()
forMOf_ = ((a -> m r) -> s -> m ()) -> s -> (a -> m r) -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((a -> m r) -> s -> m ()) -> s -> (a -> m r) -> m ())
-> (Getting (Sequenced r m) s a -> (a -> m r) -> s -> m ())
-> Getting (Sequenced r m) s a
-> s
-> (a -> m r)
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Sequenced r m) s a -> (a -> m r) -> s -> m ()
forall (m :: * -> *) r s a.
Monad m =>
Getting (Sequenced r m) s a -> (a -> m r) -> s -> m ()
mapMOf_
{-# INLINE forMOf_ #-}
sequenceOf_ :: Monad m => Getting (Sequenced a m) s (m a) -> s -> m ()
sequenceOf_ :: forall (m :: * -> *) a s.
Monad m =>
Getting (Sequenced a m) s (m a) -> s -> m ()
sequenceOf_ Getting (Sequenced a m) s (m a)
l = (a -> ()) -> m a -> m ()
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> ()
forall a. a -> ()
skip (m a -> m ()) -> (s -> m a) -> s -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sequenced a m -> m a
forall a (m :: * -> *). Sequenced a m -> m a
getSequenced (Sequenced a m -> m a) -> (s -> Sequenced a m) -> s -> m a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting (Sequenced a m) s (m a)
-> (m a -> Sequenced a m) -> s -> Sequenced a m
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Sequenced a m) s (m a)
l m a -> Sequenced a m
forall a (m :: * -> *). m a -> Sequenced a m
Sequenced
{-# INLINE sequenceOf_ #-}
asumOf :: Alternative f => Getting (Endo (f a)) s (f a) -> s -> f a
asumOf :: forall (f :: * -> *) a s.
Alternative f =>
Getting (Endo (f a)) s (f a) -> s -> f a
asumOf Getting (Endo (f a)) s (f a)
l = Getting (Endo (f a)) s (f a)
-> (f a -> f a -> f a) -> f a -> s -> f a
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo (f a)) s (f a)
l f a -> f a -> f a
forall a. f a -> f a -> f a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>) f a
forall a. f a
forall (f :: * -> *) a. Alternative f => f a
empty
{-# INLINE asumOf #-}
msumOf :: MonadPlus m => Getting (Endo (m a)) s (m a) -> s -> m a
msumOf :: forall (m :: * -> *) a s.
MonadPlus m =>
Getting (Endo (m a)) s (m a) -> s -> m a
msumOf Getting (Endo (m a)) s (m a)
l = Getting (Endo (m a)) s (m a)
-> (m a -> m a -> m a) -> m a -> s -> m a
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo (m a)) s (m a)
l m a -> m a -> m a
forall a. m a -> m a -> m a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus m a
forall a. m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
{-# INLINE msumOf #-}
elemOf :: Eq a => Getting Any s a -> a -> s -> Bool
elemOf :: forall a s. Eq a => Getting Any s a -> a -> s -> Bool
elemOf Getting Any s a
l = Getting Any s a -> (a -> Bool) -> s -> Bool
forall s a. Getting Any s a -> (a -> Bool) -> s -> Bool
anyOf Getting Any s a
l ((a -> Bool) -> s -> Bool) -> (a -> a -> Bool) -> a -> s -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> Bool
forall a. Eq a => a -> a -> Bool
(==)
{-# INLINE elemOf #-}
notElemOf :: Eq a => Getting All s a -> a -> s -> Bool
notElemOf :: forall a s. Eq a => Getting All s a -> a -> s -> Bool
notElemOf Getting All s a
l = Getting All s a -> (a -> Bool) -> s -> Bool
forall s a. Getting All s a -> (a -> Bool) -> s -> Bool
allOf Getting All s a
l ((a -> Bool) -> s -> Bool) -> (a -> a -> Bool) -> a -> s -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> Bool
forall a. Eq a => a -> a -> Bool
(/=)
{-# INLINE notElemOf #-}
concatMapOf :: Getting [r] s a -> (a -> [r]) -> s -> [r]
concatMapOf :: forall r s a. Getting [r] s a -> (a -> [r]) -> s -> [r]
concatMapOf = Getting [r] s a -> (a -> [r]) -> s -> [r]
forall a b. Coercible a b => a -> b
coerce
{-# INLINE concatMapOf #-}
concatOf :: Getting [r] s [r] -> s -> [r]
concatOf :: forall r s. Getting [r] s [r] -> s -> [r]
concatOf Getting [r] s [r]
l = Const [r] s -> [r]
forall {k} a (b :: k). Const a b -> a
getConst (Const [r] s -> [r]) -> (s -> Const [r] s) -> s -> [r]
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting [r] s [r]
l [r] -> Const [r] [r]
forall {k} a (b :: k). a -> Const a b
Const
{-# INLINE concatOf #-}
lengthOf :: Getting (Endo (Endo Int)) s a -> s -> Int
lengthOf :: forall s a. Getting (Endo (Endo Int)) s a -> s -> Int
lengthOf Getting (Endo (Endo Int)) s a
l = Getting (Endo (Endo Int)) s a
-> (Int -> a -> Int) -> Int -> s -> Int
forall r s a.
Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' Getting (Endo (Endo Int)) s a
l (\Int
a a
_ -> Int
a Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Int
0
{-# INLINE lengthOf #-}
(^?) :: s -> Getting (First a) s a -> Maybe a
s
s ^? :: forall s a. s -> Getting (First a) s a -> Maybe a
^? Getting (First a) s a
l = First a -> Maybe a
forall a. First a -> Maybe a
getFirst (Getting (First a) s a -> (a -> First a) -> s -> First a
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (First a) s a
l (Maybe a -> First a
forall a. Maybe a -> First a
First (Maybe a -> First a) -> (a -> Maybe a) -> a -> First a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> Maybe a
forall a. a -> Maybe a
Just) s
s)
{-# INLINE (^?) #-}
(^?!) :: HasCallStack => s -> Getting (Endo a) s a -> a
s
s ^?! :: forall s a. HasCallStack => s -> Getting (Endo a) s a -> a
^?! Getting (Endo a) s a
l = Getting (Endo a) s a -> (a -> a -> a) -> a -> s -> a
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo a) s a
l a -> a -> a
forall a b. a -> b -> a
const (String -> a
forall a. HasCallStack => String -> a
error String
"(^?!): empty Fold") s
s
{-# INLINE (^?!) #-}
firstOf :: Getting (Leftmost a) s a -> s -> Maybe a
firstOf :: forall a s. Getting (Leftmost a) s a -> s -> Maybe a
firstOf Getting (Leftmost a) s a
l = Leftmost a -> Maybe a
forall a. Leftmost a -> Maybe a
getLeftmost (Leftmost a -> Maybe a) -> (s -> Leftmost a) -> s -> Maybe a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Leftmost a) s a -> (a -> Leftmost a) -> s -> Leftmost a
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Leftmost a) s a
l a -> Leftmost a
forall a. a -> Leftmost a
LLeaf
{-# INLINE firstOf #-}
first1Of :: Getting (Semi.First a) s a -> s -> a
first1Of :: forall a s. Getting (First a) s a -> s -> a
first1Of Getting (First a) s a
l = First a -> a
forall a. First a -> a
Semi.getFirst (First a -> a) -> (s -> First a) -> s -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First a) s a -> (a -> First a) -> s -> First a
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (First a) s a
l a -> First a
forall a. a -> First a
Semi.First
lastOf :: Getting (Rightmost a) s a -> s -> Maybe a
lastOf :: forall a s. Getting (Rightmost a) s a -> s -> Maybe a
lastOf Getting (Rightmost a) s a
l = Rightmost a -> Maybe a
forall a. Rightmost a -> Maybe a
getRightmost (Rightmost a -> Maybe a) -> (s -> Rightmost a) -> s -> Maybe a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Rightmost a) s a -> (a -> Rightmost a) -> s -> Rightmost a
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Rightmost a) s a
l a -> Rightmost a
forall a. a -> Rightmost a
RLeaf
{-# INLINE lastOf #-}
last1Of :: Getting (Semi.Last a) s a -> s -> a
last1Of :: forall a s. Getting (Last a) s a -> s -> a
last1Of Getting (Last a) s a
l = Last a -> a
forall a. Last a -> a
Semi.getLast (Last a -> a) -> (s -> Last a) -> s -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Last a) s a -> (a -> Last a) -> s -> Last a
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Last a) s a
l a -> Last a
forall a. a -> Last a
Semi.Last
nullOf :: Getting All s a -> s -> Bool
nullOf :: forall s a. Getting All s a -> s -> Bool
nullOf = Getting All s a -> s -> Bool
forall s a. Getting All s a -> s -> Bool
hasn't
{-# INLINE nullOf #-}
notNullOf :: Getting Any s a -> s -> Bool
notNullOf :: forall s a. Getting Any s a -> s -> Bool
notNullOf = Getting Any s a -> s -> Bool
forall s a. Getting Any s a -> s -> Bool
has
{-# INLINE notNullOf #-}
maximumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a
maximumOf :: forall a s.
Ord a =>
Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a
maximumOf Getting (Endo (Endo (Maybe a))) s a
l = Getting (Endo (Endo (Maybe a))) s a
-> (Maybe a -> a -> Maybe a) -> Maybe a -> s -> Maybe a
forall r s a.
Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' Getting (Endo (Endo (Maybe a))) s a
l Maybe a -> a -> Maybe a
forall {a}. Ord a => Maybe a -> a -> Maybe a
mf Maybe a
forall a. Maybe a
Nothing where
mf :: Maybe a -> a -> Maybe a
mf Maybe a
Nothing a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a
y
mf (Just a
x) a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a -> a -> a
forall a. Ord a => a -> a -> a
max a
x a
y
{-# INLINE maximumOf #-}
maximum1Of :: Ord a => Getting (Semi.Max a) s a -> s -> a
maximum1Of :: forall a s. Ord a => Getting (Max a) s a -> s -> a
maximum1Of Getting (Max a) s a
l = Max a -> a
forall a. Max a -> a
Semi.getMax (Max a -> a) -> (s -> Max a) -> s -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Max a) s a -> (a -> Max a) -> s -> Max a
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Max a) s a
l a -> Max a
forall a. a -> Max a
Semi.Max
{-# INLINE maximum1Of #-}
minimumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a
minimumOf :: forall a s.
Ord a =>
Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a
minimumOf Getting (Endo (Endo (Maybe a))) s a
l = Getting (Endo (Endo (Maybe a))) s a
-> (Maybe a -> a -> Maybe a) -> Maybe a -> s -> Maybe a
forall r s a.
Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' Getting (Endo (Endo (Maybe a))) s a
l Maybe a -> a -> Maybe a
forall {a}. Ord a => Maybe a -> a -> Maybe a
mf Maybe a
forall a. Maybe a
Nothing where
mf :: Maybe a -> a -> Maybe a
mf Maybe a
Nothing a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a
y
mf (Just a
x) a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a -> a -> a
forall a. Ord a => a -> a -> a
min a
x a
y
{-# INLINE minimumOf #-}
minimum1Of :: Ord a => Getting (Semi.Min a) s a -> s -> a
minimum1Of :: forall a s. Ord a => Getting (Min a) s a -> s -> a
minimum1Of Getting (Min a) s a
l = Min a -> a
forall a. Min a -> a
Semi.getMin (Min a -> a) -> (s -> Min a) -> s -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Min a) s a -> (a -> Min a) -> s -> Min a
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (Min a) s a
l a -> Min a
forall a. a -> Min a
Semi.Min
{-# INLINE minimum1Of #-}
maximumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a
maximumByOf :: forall a s.
Getting (Endo (Endo (Maybe a))) s a
-> (a -> a -> Ordering) -> s -> Maybe a
maximumByOf Getting (Endo (Endo (Maybe a))) s a
l a -> a -> Ordering
cmp = Getting (Endo (Endo (Maybe a))) s a
-> (Maybe a -> a -> Maybe a) -> Maybe a -> s -> Maybe a
forall r s a.
Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' Getting (Endo (Endo (Maybe a))) s a
l Maybe a -> a -> Maybe a
mf Maybe a
forall a. Maybe a
Nothing where
mf :: Maybe a -> a -> Maybe a
mf Maybe a
Nothing a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a
y
mf (Just a
x) a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! if a -> a -> Ordering
cmp a
x a
y Ordering -> Ordering -> Bool
forall a. Eq a => a -> a -> Bool
== Ordering
GT then a
x else a
y
{-# INLINE maximumByOf #-}
minimumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a
minimumByOf :: forall a s.
Getting (Endo (Endo (Maybe a))) s a
-> (a -> a -> Ordering) -> s -> Maybe a
minimumByOf Getting (Endo (Endo (Maybe a))) s a
l a -> a -> Ordering
cmp = Getting (Endo (Endo (Maybe a))) s a
-> (Maybe a -> a -> Maybe a) -> Maybe a -> s -> Maybe a
forall r s a.
Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' Getting (Endo (Endo (Maybe a))) s a
l Maybe a -> a -> Maybe a
mf Maybe a
forall a. Maybe a
Nothing where
mf :: Maybe a -> a -> Maybe a
mf Maybe a
Nothing a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a
y
mf (Just a
x) a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! if a -> a -> Ordering
cmp a
x a
y Ordering -> Ordering -> Bool
forall a. Eq a => a -> a -> Bool
== Ordering
GT then a
y else a
x
{-# INLINE minimumByOf #-}
findOf :: Getting (Endo (Maybe a)) s a -> (a -> Bool) -> s -> Maybe a
findOf :: forall a s.
Getting (Endo (Maybe a)) s a -> (a -> Bool) -> s -> Maybe a
findOf Getting (Endo (Maybe a)) s a
l a -> Bool
f = Getting (Endo (Maybe a)) s a
-> (a -> Maybe a -> Maybe a) -> Maybe a -> s -> Maybe a
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo (Maybe a)) s a
l (\a
a Maybe a
y -> if a -> Bool
f a
a then a -> Maybe a
forall a. a -> Maybe a
Just a
a else Maybe a
y) Maybe a
forall a. Maybe a
Nothing
{-# INLINE findOf #-}
findMOf :: Monad m => Getting (Endo (m (Maybe a))) s a -> (a -> m Bool) -> s -> m (Maybe a)
findMOf :: forall (m :: * -> *) a s.
Monad m =>
Getting (Endo (m (Maybe a))) s a
-> (a -> m Bool) -> s -> m (Maybe a)
findMOf Getting (Endo (m (Maybe a))) s a
l a -> m Bool
f = Getting (Endo (m (Maybe a))) s a
-> (a -> m (Maybe a) -> m (Maybe a))
-> m (Maybe a)
-> s
-> m (Maybe a)
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo (m (Maybe a))) s a
l (\a
a m (Maybe a)
y -> a -> m Bool
f a
a m Bool -> (Bool -> m (Maybe a)) -> m (Maybe a)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
r -> if Bool
r then Maybe a -> m (Maybe a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Maybe a
forall a. a -> Maybe a
Just a
a) else m (Maybe a)
y) (m (Maybe a) -> s -> m (Maybe a))
-> m (Maybe a) -> s -> m (Maybe a)
forall a b. (a -> b) -> a -> b
$ Maybe a -> m (Maybe a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
{-# INLINE findMOf #-}
lookupOf :: Eq k => Getting (Endo (Maybe v)) s (k,v) -> k -> s -> Maybe v
lookupOf :: forall k v s.
Eq k =>
Getting (Endo (Maybe v)) s (k, v) -> k -> s -> Maybe v
lookupOf Getting (Endo (Maybe v)) s (k, v)
l k
k = Getting (Endo (Maybe v)) s (k, v)
-> ((k, v) -> Maybe v -> Maybe v) -> Maybe v -> s -> Maybe v
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo (Maybe v)) s (k, v)
l (\(k
k',v
v) Maybe v
next -> if k
k k -> k -> Bool
forall a. Eq a => a -> a -> Bool
== k
k' then v -> Maybe v
forall a. a -> Maybe a
Just v
v else Maybe v
next) Maybe v
forall a. Maybe a
Nothing
{-# INLINE lookupOf #-}
foldr1Of :: HasCallStack => Getting (Endo (Maybe a)) s a -> (a -> a -> a) -> s -> a
foldr1Of :: forall a s.
HasCallStack =>
Getting (Endo (Maybe a)) s a -> (a -> a -> a) -> s -> a
foldr1Of Getting (Endo (Maybe a)) s a
l a -> a -> a
f s
xs = a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe (String -> a
forall a. HasCallStack => String -> a
error String
"foldr1Of: empty structure")
(Getting (Endo (Maybe a)) s a
-> (a -> Maybe a -> Maybe a) -> Maybe a -> s -> Maybe a
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo (Maybe a)) s a
l a -> Maybe a -> Maybe a
mf Maybe a
forall a. Maybe a
Nothing s
xs) where
mf :: a -> Maybe a -> Maybe a
mf a
x Maybe a
my = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$ case Maybe a
my of
Maybe a
Nothing -> a
x
Just a
y -> a -> a -> a
f a
x a
y
{-# INLINE foldr1Of #-}
foldl1Of :: HasCallStack => Getting (Dual (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> a
foldl1Of :: forall a s.
HasCallStack =>
Getting (Dual (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> a
foldl1Of Getting (Dual (Endo (Maybe a))) s a
l a -> a -> a
f s
xs = a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe (String -> a
forall a. HasCallStack => String -> a
error String
"foldl1Of: empty structure") (Getting (Dual (Endo (Maybe a))) s a
-> (Maybe a -> a -> Maybe a) -> Maybe a -> s -> Maybe a
forall r s a.
Getting (Dual (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf Getting (Dual (Endo (Maybe a))) s a
l Maybe a -> a -> Maybe a
mf Maybe a
forall a. Maybe a
Nothing s
xs) where
mf :: Maybe a -> a -> Maybe a
mf Maybe a
mx a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$ case Maybe a
mx of
Maybe a
Nothing -> a
y
Just a
x -> a -> a -> a
f a
x a
y
{-# INLINE foldl1Of #-}
foldrOf' :: Getting (Dual (Endo (Endo r))) s a -> (a -> r -> r) -> r -> s -> r
foldrOf' :: forall r s a.
Getting (Dual (Endo (Endo r))) s a -> (a -> r -> r) -> r -> s -> r
foldrOf' Getting (Dual (Endo (Endo r))) s a
l a -> r -> r
f r
z0 s
xs = Getting (Dual (Endo (Endo r))) s a
-> (Endo r -> a -> Endo r) -> Endo r -> s -> Endo r
forall r s a.
Getting (Dual (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf Getting (Dual (Endo (Endo r))) s a
l Endo r -> a -> Endo r
f' ((r -> r) -> Endo r
forall a. (a -> a) -> Endo a
Endo r -> r
forall a. a -> a
id) s
xs Endo r -> r -> r
forall a. Endo a -> a -> a
`appEndo` r
z0
where f' :: Endo r -> a -> Endo r
f' (Endo r -> r
k) a
x = (r -> r) -> Endo r
forall a. (a -> a) -> Endo a
Endo ((r -> r) -> Endo r) -> (r -> r) -> Endo r
forall a b. (a -> b) -> a -> b
$ \ r
z -> r -> r
k (r -> r) -> r -> r
forall a b. (a -> b) -> a -> b
$! a -> r -> r
f a
x r
z
{-# INLINE foldrOf' #-}
foldlOf' :: Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' :: forall r s a.
Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' Getting (Endo (Endo r)) s a
l r -> a -> r
f r
z0 s
xs = Getting (Endo (Endo r)) s a
-> (a -> Endo r -> Endo r) -> Endo r -> s -> Endo r
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo (Endo r)) s a
l a -> Endo r -> Endo r
f' ((r -> r) -> Endo r
forall a. (a -> a) -> Endo a
Endo r -> r
forall a. a -> a
id) s
xs Endo r -> r -> r
forall a. Endo a -> a -> a
`appEndo` r
z0
where f' :: a -> Endo r -> Endo r
f' a
x (Endo r -> r
k) = (r -> r) -> Endo r
forall a. (a -> a) -> Endo a
Endo ((r -> r) -> Endo r) -> (r -> r) -> Endo r
forall a b. (a -> b) -> a -> b
$ \r
z -> r -> r
k (r -> r) -> r -> r
forall a b. (a -> b) -> a -> b
$! r -> a -> r
f r
z a
x
{-# INLINE foldlOf' #-}
foldr1Of' :: HasCallStack => Getting (Dual (Endo (Endo (Maybe a)))) s a -> (a -> a -> a) -> s -> a
foldr1Of' :: forall a s.
HasCallStack =>
Getting (Dual (Endo (Endo (Maybe a)))) s a
-> (a -> a -> a) -> s -> a
foldr1Of' Getting (Dual (Endo (Endo (Maybe a)))) s a
l a -> a -> a
f s
xs = a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe (String -> a
forall a. HasCallStack => String -> a
error String
"foldr1Of': empty structure") (Getting (Dual (Endo (Endo (Maybe a)))) s a
-> (a -> Maybe a -> Maybe a) -> Maybe a -> s -> Maybe a
forall r s a.
Getting (Dual (Endo (Endo r))) s a -> (a -> r -> r) -> r -> s -> r
foldrOf' Getting (Dual (Endo (Endo (Maybe a)))) s a
l a -> Maybe a -> Maybe a
mf Maybe a
forall a. Maybe a
Nothing s
xs) where
mf :: a -> Maybe a -> Maybe a
mf a
x Maybe a
Nothing = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a
x
mf a
x (Just a
y) = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a -> a -> a
f a
x a
y
{-# INLINE foldr1Of' #-}
foldl1Of' :: HasCallStack => Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> a
foldl1Of' :: forall a s.
HasCallStack =>
Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> a
foldl1Of' Getting (Endo (Endo (Maybe a))) s a
l a -> a -> a
f s
xs = a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe (String -> a
forall a. HasCallStack => String -> a
error String
"foldl1Of': empty structure") (Getting (Endo (Endo (Maybe a))) s a
-> (Maybe a -> a -> Maybe a) -> Maybe a -> s -> Maybe a
forall r s a.
Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf' Getting (Endo (Endo (Maybe a))) s a
l Maybe a -> a -> Maybe a
mf Maybe a
forall a. Maybe a
Nothing s
xs) where
mf :: Maybe a -> a -> Maybe a
mf Maybe a
Nothing a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a
y
mf (Just a
x) a
y = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a -> a -> a
f a
x a
y
{-# INLINE foldl1Of' #-}
foldrMOf :: Monad m
=> Getting (Dual (Endo (r -> m r))) s a
-> (a -> r -> m r) -> r -> s -> m r
foldrMOf :: forall (m :: * -> *) r s a.
Monad m =>
Getting (Dual (Endo (r -> m r))) s a
-> (a -> r -> m r) -> r -> s -> m r
foldrMOf Getting (Dual (Endo (r -> m r))) s a
l a -> r -> m r
f r
z0 s
xs = Getting (Dual (Endo (r -> m r))) s a
-> ((r -> m r) -> a -> r -> m r) -> (r -> m r) -> s -> r -> m r
forall r s a.
Getting (Dual (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
foldlOf Getting (Dual (Endo (r -> m r))) s a
l (r -> m r) -> a -> r -> m r
forall {b}. (r -> m b) -> a -> r -> m b
f' r -> m r
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return s
xs r
z0
where f' :: (r -> m b) -> a -> r -> m b
f' r -> m b
k a
x r
z = a -> r -> m r
f a
x r
z m r -> (r -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= r -> m b
k
{-# INLINE foldrMOf #-}
foldlMOf :: Monad m
=> Getting (Endo (r -> m r)) s a
-> (r -> a -> m r) -> r -> s -> m r
foldlMOf :: forall (m :: * -> *) r s a.
Monad m =>
Getting (Endo (r -> m r)) s a -> (r -> a -> m r) -> r -> s -> m r
foldlMOf Getting (Endo (r -> m r)) s a
l r -> a -> m r
f r
z0 s
xs = Getting (Endo (r -> m r)) s a
-> (a -> (r -> m r) -> r -> m r) -> (r -> m r) -> s -> r -> m r
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo (r -> m r)) s a
l a -> (r -> m r) -> r -> m r
forall {b}. a -> (r -> m b) -> r -> m b
f' r -> m r
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return s
xs r
z0
where f' :: a -> (r -> m b) -> r -> m b
f' a
x r -> m b
k r
z = r -> a -> m r
f r
z a
x m r -> (r -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= r -> m b
k
{-# INLINE foldlMOf #-}
has :: Getting Any s a -> s -> Bool
has :: forall s a. Getting Any s a -> s -> Bool
has Getting Any s a
l = Any -> Bool
getAny (Any -> Bool) -> (s -> Any) -> s -> Bool
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting Any s a -> (a -> Any) -> s -> Any
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting Any s a
l (\a
_ -> Bool -> Any
Any Bool
True)
{-# INLINE has #-}
hasn't :: Getting All s a -> s -> Bool
hasn't :: forall s a. Getting All s a -> s -> Bool
hasn't Getting All s a
l = All -> Bool
getAll (All -> Bool) -> (s -> All) -> s -> Bool
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting All s a -> (a -> All) -> s -> All
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting All s a
l (\a
_ -> Bool -> All
All Bool
False)
{-# INLINE hasn't #-}
pre :: Getting (First a) s a -> IndexPreservingGetter s (Maybe a)
pre :: forall a s.
Getting (First a) s a -> IndexPreservingGetter s (Maybe a)
pre Getting (First a) s a
l = (s -> Maybe a)
-> (f (Maybe a) -> f s) -> p (Maybe a) (f (Maybe a)) -> p s (f s)
forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (First a -> Maybe a
forall a. First a -> Maybe a
getFirst (First a -> Maybe a) -> (s -> First a) -> s -> Maybe a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const (First a) s -> First a
forall {k} a (b :: k). Const a b -> a
getConst (Const (First a) s -> First a)
-> (s -> Const (First a) s) -> s -> First a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting (First a) s a
l (First a -> Const (First a) a
forall {k} a (b :: k). a -> Const a b
Const (First a -> Const (First a) a)
-> (a -> First a) -> a -> Const (First a) a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Maybe a -> First a
forall a. Maybe a -> First a
First (Maybe a -> First a) -> (a -> Maybe a) -> a -> First a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> Maybe a
forall a. a -> Maybe a
Just)) f (Maybe a) -> f s
forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom
{-# INLINE pre #-}
ipre :: IndexedGetting i (First (i, a)) s a -> IndexPreservingGetter s (Maybe (i, a))
ipre :: forall i a s.
IndexedGetting i (First (i, a)) s a
-> IndexPreservingGetter s (Maybe (i, a))
ipre IndexedGetting i (First (i, a)) s a
l = (s -> Maybe (i, a))
-> (f (Maybe (i, a)) -> f s)
-> p (Maybe (i, a)) (f (Maybe (i, a)))
-> p s (f s)
forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (First (i, a) -> Maybe (i, a)
forall a. First a -> Maybe a
getFirst (First (i, a) -> Maybe (i, a))
-> (s -> First (i, a)) -> s -> Maybe (i, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const (First (i, a)) s -> First (i, a)
forall {k} a (b :: k). Const a b -> a
getConst (Const (First (i, a)) s -> First (i, a))
-> (s -> Const (First (i, a)) s) -> s -> First (i, a)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. IndexedGetting i (First (i, a)) s a
l ((i -> a -> Const (First (i, a)) a)
-> Indexed i a (Const (First (i, a)) a)
forall i a b. (i -> a -> b) -> Indexed i a b
Indexed ((i -> a -> Const (First (i, a)) a)
-> Indexed i a (Const (First (i, a)) a))
-> (i -> a -> Const (First (i, a)) a)
-> Indexed i a (Const (First (i, a)) a)
forall a b. (a -> b) -> a -> b
$ \i
i a
a -> First (i, a) -> Const (First (i, a)) a
forall {k} a (b :: k). a -> Const a b
Const (Maybe (i, a) -> First (i, a)
forall a. Maybe a -> First a
First ((i, a) -> Maybe (i, a)
forall a. a -> Maybe a
Just (i
i, a
a))))) f (Maybe (i, a)) -> f s
forall (f :: * -> *) a b.
(Functor f, Contravariant f) =>
f a -> f b
phantom
{-# INLINE ipre #-}
preview :: MonadReader s m => Getting (First a) s a -> m (Maybe a)
preview :: forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview Getting (First a) s a
l = (s -> Maybe a) -> m (Maybe a)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks (First a -> Maybe a
forall a. First a -> Maybe a
getFirst (First a -> Maybe a) -> (s -> First a) -> s -> Maybe a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Getting (First a) s a -> (a -> First a) -> s -> First a
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (First a) s a
l (Maybe a -> First a
forall a. Maybe a -> First a
First (Maybe a -> First a) -> (a -> Maybe a) -> a -> First a
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> Maybe a
forall a. a -> Maybe a
Just))
{-# INLINE preview #-}
ipreview :: MonadReader s m => IndexedGetting i (First (i, a)) s a -> m (Maybe (i, a))
ipreview :: forall s (m :: * -> *) i a.
MonadReader s m =>
IndexedGetting i (First (i, a)) s a -> m (Maybe (i, a))
ipreview IndexedGetting i (First (i, a)) s a
l = (s -> Maybe (i, a)) -> m (Maybe (i, a))
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks (First (i, a) -> Maybe (i, a)
forall a. First a -> Maybe a
getFirst (First (i, a) -> Maybe (i, a))
-> (s -> First (i, a)) -> s -> Maybe (i, a)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. IndexedGetting i (First (i, a)) s a
-> (i -> a -> First (i, a)) -> s -> First (i, a)
forall i m s a. IndexedGetting i m s a -> (i -> a -> m) -> s -> m
ifoldMapOf IndexedGetting i (First (i, a)) s a
l (\i
i a
a -> Maybe (i, a) -> First (i, a)
forall a. Maybe a -> First a
First ((i, a) -> Maybe (i, a)
forall a. a -> Maybe a
Just (i
i, a
a))))
{-# INLINE ipreview #-}
previews :: MonadReader s m => Getting (First r) s a -> (a -> r) -> m (Maybe r)
previews :: forall s (m :: * -> *) r a.
MonadReader s m =>
Getting (First r) s a -> (a -> r) -> m (Maybe r)
previews Getting (First r) s a
l a -> r
f = (s -> Maybe r) -> m (Maybe r)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks (First r -> Maybe r
forall a. First a -> Maybe a
getFirst (First r -> Maybe r) -> (s -> First r) -> s -> Maybe r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First r) s a -> (a -> First r) -> s -> First r
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (First r) s a
l (Maybe r -> First r
forall a. Maybe a -> First a
First (Maybe r -> First r) -> (a -> Maybe r) -> a -> First r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. r -> Maybe r
forall a. a -> Maybe a
Just (r -> Maybe r) -> (a -> r) -> a -> Maybe r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> r
f))
{-# INLINE previews #-}
ipreviews :: MonadReader s m => IndexedGetting i (First r) s a -> (i -> a -> r) -> m (Maybe r)
ipreviews :: forall s (m :: * -> *) i r a.
MonadReader s m =>
IndexedGetting i (First r) s a -> (i -> a -> r) -> m (Maybe r)
ipreviews IndexedGetting i (First r) s a
l i -> a -> r
f = (s -> Maybe r) -> m (Maybe r)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks (First r -> Maybe r
forall a. First a -> Maybe a
getFirst (First r -> Maybe r) -> (s -> First r) -> s -> Maybe r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndexedGetting i (First r) s a
-> (i -> a -> First r) -> s -> First r
forall i m s a. IndexedGetting i m s a -> (i -> a -> m) -> s -> m
ifoldMapOf IndexedGetting i (First r) s a
l (\i
i -> Maybe r -> First r
forall a. Maybe a -> First a
First (Maybe r -> First r) -> (a -> Maybe r) -> a -> First r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. r -> Maybe r
forall a. a -> Maybe a
Just (r -> Maybe r) -> (a -> r) -> a -> Maybe r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> a -> r
f i
i))
{-# INLINE ipreviews #-}
preuse :: MonadState s m => Getting (First a) s a -> m (Maybe a)
preuse :: forall s (m :: * -> *) a.
MonadState s m =>
Getting (First a) s a -> m (Maybe a)
preuse Getting (First a) s a
l = (s -> Maybe a) -> m (Maybe a)
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets (Getting (First a) s a -> s -> Maybe a
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview Getting (First a) s a
l)
{-# INLINE preuse #-}
ipreuse :: MonadState s m => IndexedGetting i (First (i, a)) s a -> m (Maybe (i, a))
ipreuse :: forall s (m :: * -> *) i a.
MonadState s m =>
IndexedGetting i (First (i, a)) s a -> m (Maybe (i, a))
ipreuse IndexedGetting i (First (i, a)) s a
l = (s -> Maybe (i, a)) -> m (Maybe (i, a))
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets (IndexedGetting i (First (i, a)) s a -> s -> Maybe (i, a)
forall s (m :: * -> *) i a.
MonadReader s m =>
IndexedGetting i (First (i, a)) s a -> m (Maybe (i, a))
ipreview IndexedGetting i (First (i, a)) s a
l)
{-# INLINE ipreuse #-}
preuses :: MonadState s m => Getting (First r) s a -> (a -> r) -> m (Maybe r)
preuses :: forall s (m :: * -> *) r a.
MonadState s m =>
Getting (First r) s a -> (a -> r) -> m (Maybe r)
preuses Getting (First r) s a
l a -> r
f = (s -> Maybe r) -> m (Maybe r)
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets (Getting (First r) s a -> (a -> r) -> s -> Maybe r
forall s (m :: * -> *) r a.
MonadReader s m =>
Getting (First r) s a -> (a -> r) -> m (Maybe r)
previews Getting (First r) s a
l a -> r
f)
{-# INLINE preuses #-}
ipreuses :: MonadState s m => IndexedGetting i (First r) s a -> (i -> a -> r) -> m (Maybe r)
ipreuses :: forall s (m :: * -> *) i r a.
MonadState s m =>
IndexedGetting i (First r) s a -> (i -> a -> r) -> m (Maybe r)
ipreuses IndexedGetting i (First r) s a
l i -> a -> r
f = (s -> Maybe r) -> m (Maybe r)
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets (IndexedGetting i (First r) s a -> (i -> a -> r) -> s -> Maybe r
forall s (m :: * -> *) i r a.
MonadReader s m =>
IndexedGetting i (First r) s a -> (i -> a -> r) -> m (Maybe r)
ipreviews IndexedGetting i (First r) s a
l i -> a -> r
f)
{-# INLINE ipreuses #-}
backwards :: (Profunctor p, Profunctor q) => Optical p q (Backwards f) s t a b -> Optical p q f s t a b
backwards :: forall (p :: * -> * -> *) (q :: * -> * -> *) (f :: * -> *) s t a b.
(Profunctor p, Profunctor q) =>
Optical p q (Backwards f) s t a b -> Optical p q f s t a b
backwards Optical p q (Backwards f) s t a b
l p a (f b)
f = Backwards f t -> f t
forall {k} (f :: k -> *) (a :: k). Backwards f a -> f a
forwards (Backwards f t -> f t) -> q s (Backwards f t) -> q s (f t)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> q a b -> q a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Optical p q (Backwards f) s t a b
l (f b -> Backwards f b
forall {k} (f :: k -> *) (a :: k). f a -> Backwards f a
Backwards (f b -> Backwards f b) -> p a (f b) -> p a (Backwards f b)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> p a b -> p a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. p a (f b)
f)
{-# INLINE backwards #-}
ifoldMapOf :: IndexedGetting i m s a -> (i -> a -> m) -> s -> m
ifoldMapOf :: forall i m s a. IndexedGetting i m s a -> (i -> a -> m) -> s -> m
ifoldMapOf = IndexedGetting i m s a -> (i -> a -> m) -> s -> m
forall a b. Coercible a b => a -> b
coerce
{-# INLINE ifoldMapOf #-}
ifoldrOf :: IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf :: forall i r s a.
IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf IndexedGetting i (Endo r) s a
l i -> a -> r -> r
f r
z = (Endo r -> r -> r) -> r -> Endo r -> r
forall a b c. (a -> b -> c) -> b -> a -> c
flip Endo r -> r -> r
forall a. Endo a -> a -> a
appEndo r
z (Endo r -> r) -> (s -> Endo r) -> s -> r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const (Endo r) s -> Endo r
forall {k} a (b :: k). Const a b -> a
getConst (Const (Endo r) s -> Endo r)
-> (s -> Const (Endo r) s) -> s -> Endo r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. IndexedGetting i (Endo r) s a
l (Endo r -> Const (Endo r) a
forall {k} a (b :: k). a -> Const a b
Const (Endo r -> Const (Endo r) a)
-> Indexed i a (Endo r) -> Indexed i a (Const (Endo r) a)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Indexed i a b -> Indexed i a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. (r -> r) -> Endo r
forall a. (a -> a) -> Endo a
Endo ((r -> r) -> Endo r)
-> Indexed i a (r -> r) -> Indexed i a (Endo r)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Indexed i a b -> Indexed i a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. (i -> a -> r -> r) -> Indexed i a (r -> r)
forall i a b. (i -> a -> b) -> Indexed i a b
Indexed i -> a -> r -> r
f)
{-# INLINE ifoldrOf #-}
ifoldlOf :: IndexedGetting i (Dual (Endo r)) s a -> (i -> r -> a -> r) -> r -> s -> r
ifoldlOf :: forall i r s a.
IndexedGetting i (Dual (Endo r)) s a
-> (i -> r -> a -> r) -> r -> s -> r
ifoldlOf IndexedGetting i (Dual (Endo r)) s a
l i -> r -> a -> r
f r
z = ((Endo r -> r -> r) -> r -> Endo r -> r
forall a b c. (a -> b -> c) -> b -> a -> c
flip Endo r -> r -> r
forall a. Endo a -> a -> a
appEndo r
z (Endo r -> r) -> (Dual (Endo r) -> Endo r) -> Dual (Endo r) -> r
forall a b c (q :: * -> * -> *).
Coercible b a =>
(b -> c) -> q a b -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# Dual (Endo r) -> Endo r
forall a. Dual a -> a
getDual) (Dual (Endo r) -> r) -> (s -> Dual (Endo r)) -> s -> r
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
`rmap` IndexedGetting i (Dual (Endo r)) s a
-> (i -> a -> Dual (Endo r)) -> s -> Dual (Endo r)
forall i m s a. IndexedGetting i m s a -> (i -> a -> m) -> s -> m
ifoldMapOf IndexedGetting i (Dual (Endo r)) s a
l (\i
i -> Endo r -> Dual (Endo r)
forall a. a -> Dual a
Dual (Endo r -> Dual (Endo r)) -> (a -> Endo r) -> a -> Dual (Endo r)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. (r -> r) -> Endo r
forall a. (a -> a) -> Endo a
Endo ((r -> r) -> Endo r) -> (a -> r -> r) -> a -> Endo r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. (r -> a -> r) -> a -> r -> r
forall a b c. (a -> b -> c) -> b -> a -> c
flip (i -> r -> a -> r
f i
i))
{-# INLINE ifoldlOf #-}
ianyOf :: IndexedGetting i Any s a -> (i -> a -> Bool) -> s -> Bool
ianyOf :: forall i s a.
IndexedGetting i Any s a -> (i -> a -> Bool) -> s -> Bool
ianyOf = IndexedGetting i Any s a -> (i -> a -> Bool) -> s -> Bool
forall a b. Coercible a b => a -> b
coerce
{-# INLINE ianyOf #-}
iallOf :: IndexedGetting i All s a -> (i -> a -> Bool) -> s -> Bool
iallOf :: forall i s a.
IndexedGetting i All s a -> (i -> a -> Bool) -> s -> Bool
iallOf = IndexedGetting i All s a -> (i -> a -> Bool) -> s -> Bool
forall a b. Coercible a b => a -> b
coerce
{-# INLINE iallOf #-}
inoneOf :: IndexedGetting i Any s a -> (i -> a -> Bool) -> s -> Bool
inoneOf :: forall i s a.
IndexedGetting i Any s a -> (i -> a -> Bool) -> s -> Bool
inoneOf IndexedGetting i Any s a
l i -> a -> Bool
f = Bool -> Bool
not (Bool -> Bool) -> (s -> Bool) -> s -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndexedGetting i Any s a -> (i -> a -> Bool) -> s -> Bool
forall i s a.
IndexedGetting i Any s a -> (i -> a -> Bool) -> s -> Bool
ianyOf IndexedGetting i Any s a
l i -> a -> Bool
f
{-# INLINE inoneOf #-}
itraverseOf_ :: Functor f => IndexedGetting i (Traversed r f) s a -> (i -> a -> f r) -> s -> f ()
itraverseOf_ :: forall (f :: * -> *) i r s a.
Functor f =>
IndexedGetting i (Traversed r f) s a
-> (i -> a -> f r) -> s -> f ()
itraverseOf_ IndexedGetting i (Traversed r f) s a
l i -> a -> f r
f = f r -> f ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (f r -> f ()) -> (s -> f r) -> s -> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Traversed r f -> f r
forall a (f :: * -> *). Traversed a f -> f a
getTraversed (Traversed r f -> f r) -> (s -> Traversed r f) -> s -> f r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Const (Traversed r f) s -> Traversed r f
forall {k} a (b :: k). Const a b -> a
getConst (Const (Traversed r f) s -> Traversed r f)
-> (s -> Const (Traversed r f) s) -> s -> Traversed r f
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. IndexedGetting i (Traversed r f) s a
l (Traversed r f -> Const (Traversed r f) a
forall {k} a (b :: k). a -> Const a b
Const (Traversed r f -> Const (Traversed r f) a)
-> Indexed i a (Traversed r f)
-> Indexed i a (Const (Traversed r f) a)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Indexed i a b -> Indexed i a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. f r -> Traversed r f
forall a (f :: * -> *). f a -> Traversed a f
Traversed (f r -> Traversed r f)
-> Indexed i a (f r) -> Indexed i a (Traversed r f)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Indexed i a b -> Indexed i a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. (i -> a -> f r) -> Indexed i a (f r)
forall i a b. (i -> a -> b) -> Indexed i a b
Indexed i -> a -> f r
f)
{-# INLINE itraverseOf_ #-}
iforOf_ :: Functor f => IndexedGetting i (Traversed r f) s a -> s -> (i -> a -> f r) -> f ()
iforOf_ :: forall (f :: * -> *) i r s a.
Functor f =>
IndexedGetting i (Traversed r f) s a
-> s -> (i -> a -> f r) -> f ()
iforOf_ = ((i -> a -> f r) -> s -> f ()) -> s -> (i -> a -> f r) -> f ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((i -> a -> f r) -> s -> f ()) -> s -> (i -> a -> f r) -> f ())
-> (IndexedGetting i (Traversed r f) s a
-> (i -> a -> f r) -> s -> f ())
-> IndexedGetting i (Traversed r f) s a
-> s
-> (i -> a -> f r)
-> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndexedGetting i (Traversed r f) s a
-> (i -> a -> f r) -> s -> f ()
forall (f :: * -> *) i r s a.
Functor f =>
IndexedGetting i (Traversed r f) s a
-> (i -> a -> f r) -> s -> f ()
itraverseOf_
{-# INLINE iforOf_ #-}
imapMOf_ :: Monad m => IndexedGetting i (Sequenced r m) s a -> (i -> a -> m r) -> s -> m ()
imapMOf_ :: forall (m :: * -> *) i r s a.
Monad m =>
IndexedGetting i (Sequenced r m) s a
-> (i -> a -> m r) -> s -> m ()
imapMOf_ IndexedGetting i (Sequenced r m) s a
l i -> a -> m r
f = (r -> ()) -> m r -> m ()
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM r -> ()
forall a. a -> ()
skip (m r -> m ()) -> (s -> m r) -> s -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sequenced r m -> m r
forall a (m :: * -> *). Sequenced a m -> m a
getSequenced (Sequenced r m -> m r) -> (s -> Sequenced r m) -> s -> m r
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. Const (Sequenced r m) s -> Sequenced r m
forall {k} a (b :: k). Const a b -> a
getConst (Const (Sequenced r m) s -> Sequenced r m)
-> (s -> Const (Sequenced r m) s) -> s -> Sequenced r m
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. IndexedGetting i (Sequenced r m) s a
l (Sequenced r m -> Const (Sequenced r m) a
forall {k} a (b :: k). a -> Const a b
Const (Sequenced r m -> Const (Sequenced r m) a)
-> Indexed i a (Sequenced r m)
-> Indexed i a (Const (Sequenced r m) a)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Indexed i a b -> Indexed i a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. m r -> Sequenced r m
forall a (m :: * -> *). m a -> Sequenced a m
Sequenced (m r -> Sequenced r m)
-> Indexed i a (m r) -> Indexed i a (Sequenced r m)
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> Indexed i a b -> Indexed i a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. (i -> a -> m r) -> Indexed i a (m r)
forall i a b. (i -> a -> b) -> Indexed i a b
Indexed i -> a -> m r
f)
{-# INLINE imapMOf_ #-}
iforMOf_ :: Monad m => IndexedGetting i (Sequenced r m) s a -> s -> (i -> a -> m r) -> m ()
iforMOf_ :: forall (m :: * -> *) i r s a.
Monad m =>
IndexedGetting i (Sequenced r m) s a
-> s -> (i -> a -> m r) -> m ()
iforMOf_ = ((i -> a -> m r) -> s -> m ()) -> s -> (i -> a -> m r) -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((i -> a -> m r) -> s -> m ()) -> s -> (i -> a -> m r) -> m ())
-> (IndexedGetting i (Sequenced r m) s a
-> (i -> a -> m r) -> s -> m ())
-> IndexedGetting i (Sequenced r m) s a
-> s
-> (i -> a -> m r)
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndexedGetting i (Sequenced r m) s a
-> (i -> a -> m r) -> s -> m ()
forall (m :: * -> *) i r s a.
Monad m =>
IndexedGetting i (Sequenced r m) s a
-> (i -> a -> m r) -> s -> m ()
imapMOf_
{-# INLINE iforMOf_ #-}
iconcatMapOf :: IndexedGetting i [r] s a -> (i -> a -> [r]) -> s -> [r]
iconcatMapOf :: forall i r s a.
IndexedGetting i [r] s a -> (i -> a -> [r]) -> s -> [r]
iconcatMapOf = IndexedGetting i [r] s a -> (i -> a -> [r]) -> s -> [r]
forall i m s a. IndexedGetting i m s a -> (i -> a -> m) -> s -> m
ifoldMapOf
{-# INLINE iconcatMapOf #-}
ifindOf :: IndexedGetting i (Endo (Maybe a)) s a -> (i -> a -> Bool) -> s -> Maybe a
ifindOf :: forall i a s.
IndexedGetting i (Endo (Maybe a)) s a
-> (i -> a -> Bool) -> s -> Maybe a
ifindOf IndexedGetting i (Endo (Maybe a)) s a
l i -> a -> Bool
f = IndexedGetting i (Endo (Maybe a)) s a
-> (i -> a -> Maybe a -> Maybe a) -> Maybe a -> s -> Maybe a
forall i r s a.
IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf IndexedGetting i (Endo (Maybe a)) s a
l (\i
i a
a Maybe a
y -> if i -> a -> Bool
f i
i a
a then a -> Maybe a
forall a. a -> Maybe a
Just a
a else Maybe a
y) Maybe a
forall a. Maybe a
Nothing
{-# INLINE ifindOf #-}
ifindMOf :: Monad m => IndexedGetting i (Endo (m (Maybe a))) s a -> (i -> a -> m Bool) -> s -> m (Maybe a)
ifindMOf :: forall (m :: * -> *) i a s.
Monad m =>
IndexedGetting i (Endo (m (Maybe a))) s a
-> (i -> a -> m Bool) -> s -> m (Maybe a)
ifindMOf IndexedGetting i (Endo (m (Maybe a))) s a
l i -> a -> m Bool
f = IndexedGetting i (Endo (m (Maybe a))) s a
-> (i -> a -> m (Maybe a) -> m (Maybe a))
-> m (Maybe a)
-> s
-> m (Maybe a)
forall i r s a.
IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf IndexedGetting i (Endo (m (Maybe a))) s a
l (\i
i a
a m (Maybe a)
y -> i -> a -> m Bool
f i
i a
a m Bool -> (Bool -> m (Maybe a)) -> m (Maybe a)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
r -> if Bool
r then Maybe a -> m (Maybe a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Maybe a
forall a. a -> Maybe a
Just a
a) else m (Maybe a)
y) (m (Maybe a) -> s -> m (Maybe a))
-> m (Maybe a) -> s -> m (Maybe a)
forall a b. (a -> b) -> a -> b
$ Maybe a -> m (Maybe a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
{-# INLINE ifindMOf #-}
ifoldrOf' :: IndexedGetting i (Dual (Endo (r -> r))) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf' :: forall i r s a.
IndexedGetting i (Dual (Endo (r -> r))) s a
-> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf' IndexedGetting i (Dual (Endo (r -> r))) s a
l i -> a -> r -> r
f r
z0 s
xs = IndexedGetting i (Dual (Endo (r -> r))) s a
-> (i -> (r -> r) -> a -> r -> r) -> (r -> r) -> s -> r -> r
forall i r s a.
IndexedGetting i (Dual (Endo r)) s a
-> (i -> r -> a -> r) -> r -> s -> r
ifoldlOf IndexedGetting i (Dual (Endo (r -> r))) s a
l i -> (r -> r) -> a -> r -> r
forall {b}. i -> (r -> b) -> a -> r -> b
f' r -> r
forall a. a -> a
id s
xs r
z0
where f' :: i -> (r -> b) -> a -> r -> b
f' i
i r -> b
k a
x r
z = r -> b
k (r -> b) -> r -> b
forall a b. (a -> b) -> a -> b
$! i -> a -> r -> r
f i
i a
x r
z
{-# INLINE ifoldrOf' #-}
ifoldlOf' :: IndexedGetting i (Endo (r -> r)) s a -> (i -> r -> a -> r) -> r -> s -> r
ifoldlOf' :: forall i r s a.
IndexedGetting i (Endo (r -> r)) s a
-> (i -> r -> a -> r) -> r -> s -> r
ifoldlOf' IndexedGetting i (Endo (r -> r)) s a
l i -> r -> a -> r
f r
z0 s
xs = IndexedGetting i (Endo (r -> r)) s a
-> (i -> a -> (r -> r) -> r -> r) -> (r -> r) -> s -> r -> r
forall i r s a.
IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf IndexedGetting i (Endo (r -> r)) s a
l i -> a -> (r -> r) -> r -> r
forall {b}. i -> a -> (r -> b) -> r -> b
f' r -> r
forall a. a -> a
id s
xs r
z0
where f' :: i -> a -> (r -> b) -> r -> b
f' i
i a
x r -> b
k r
z = r -> b
k (r -> b) -> r -> b
forall a b. (a -> b) -> a -> b
$! i -> r -> a -> r
f i
i r
z a
x
{-# INLINE ifoldlOf' #-}
ifoldrMOf :: Monad m => IndexedGetting i (Dual (Endo (r -> m r))) s a -> (i -> a -> r -> m r) -> r -> s -> m r
ifoldrMOf :: forall (m :: * -> *) i r s a.
Monad m =>
IndexedGetting i (Dual (Endo (r -> m r))) s a
-> (i -> a -> r -> m r) -> r -> s -> m r
ifoldrMOf IndexedGetting i (Dual (Endo (r -> m r))) s a
l i -> a -> r -> m r
f r
z0 s
xs = IndexedGetting i (Dual (Endo (r -> m r))) s a
-> (i -> (r -> m r) -> a -> r -> m r)
-> (r -> m r)
-> s
-> r
-> m r
forall i r s a.
IndexedGetting i (Dual (Endo r)) s a
-> (i -> r -> a -> r) -> r -> s -> r
ifoldlOf IndexedGetting i (Dual (Endo (r -> m r))) s a
l i -> (r -> m r) -> a -> r -> m r
forall {b}. i -> (r -> m b) -> a -> r -> m b
f' r -> m r
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return s
xs r
z0
where f' :: i -> (r -> m b) -> a -> r -> m b
f' i
i r -> m b
k a
x r
z = i -> a -> r -> m r
f i
i a
x r
z m r -> (r -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= r -> m b
k
{-# INLINE ifoldrMOf #-}
ifoldlMOf :: Monad m => IndexedGetting i (Endo (r -> m r)) s a -> (i -> r -> a -> m r) -> r -> s -> m r
ifoldlMOf :: forall (m :: * -> *) i r s a.
Monad m =>
IndexedGetting i (Endo (r -> m r)) s a
-> (i -> r -> a -> m r) -> r -> s -> m r
ifoldlMOf IndexedGetting i (Endo (r -> m r)) s a
l i -> r -> a -> m r
f r
z0 s
xs = IndexedGetting i (Endo (r -> m r)) s a
-> (i -> a -> (r -> m r) -> r -> m r)
-> (r -> m r)
-> s
-> r
-> m r
forall i r s a.
IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf IndexedGetting i (Endo (r -> m r)) s a
l i -> a -> (r -> m r) -> r -> m r
forall {b}. i -> a -> (r -> m b) -> r -> m b
f' r -> m r
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return s
xs r
z0
where f' :: i -> a -> (r -> m b) -> r -> m b
f' i
i a
x r -> m b
k r
z = i -> r -> a -> m r
f i
i r
z a
x m r -> (r -> m b) -> m b
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= r -> m b
k
{-# INLINE ifoldlMOf #-}
itoListOf :: IndexedGetting i (Endo [(i,a)]) s a -> s -> [(i,a)]
itoListOf :: forall i a s. IndexedGetting i (Endo [(i, a)]) s a -> s -> [(i, a)]
itoListOf IndexedGetting i (Endo [(i, a)]) s a
l = IndexedGetting i (Endo [(i, a)]) s a
-> (i -> a -> [(i, a)] -> [(i, a)]) -> [(i, a)] -> s -> [(i, a)]
forall i r s a.
IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf IndexedGetting i (Endo [(i, a)]) s a
l (\i
i a
a -> ((i
i,a
a)(i, a) -> [(i, a)] -> [(i, a)]
forall a. a -> [a] -> [a]
:)) []
{-# INLINE itoListOf #-}
(^@..) :: s -> IndexedGetting i (Endo [(i,a)]) s a -> [(i,a)]
s
s ^@.. :: forall s i a. s -> IndexedGetting i (Endo [(i, a)]) s a -> [(i, a)]
^@.. IndexedGetting i (Endo [(i, a)]) s a
l = IndexedGetting i (Endo [(i, a)]) s a
-> (i -> a -> [(i, a)] -> [(i, a)]) -> [(i, a)] -> s -> [(i, a)]
forall i r s a.
IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf IndexedGetting i (Endo [(i, a)]) s a
l (\i
i a
a -> ((i
i,a
a)(i, a) -> [(i, a)] -> [(i, a)]
forall a. a -> [a] -> [a]
:)) [] s
s
{-# INLINE (^@..) #-}
(^@?) :: s -> IndexedGetting i (Endo (Maybe (i, a))) s a -> Maybe (i, a)
s
s ^@? :: forall s i a.
s -> IndexedGetting i (Endo (Maybe (i, a))) s a -> Maybe (i, a)
^@? IndexedGetting i (Endo (Maybe (i, a))) s a
l = IndexedGetting i (Endo (Maybe (i, a))) s a
-> (i -> a -> Maybe (i, a) -> Maybe (i, a))
-> Maybe (i, a)
-> s
-> Maybe (i, a)
forall i r s a.
IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf IndexedGetting i (Endo (Maybe (i, a))) s a
l (\i
i a
x Maybe (i, a)
_ -> (i, a) -> Maybe (i, a)
forall a. a -> Maybe a
Just (i
i,a
x)) Maybe (i, a)
forall a. Maybe a
Nothing s
s
{-# INLINE (^@?) #-}
(^@?!) :: HasCallStack => s -> IndexedGetting i (Endo (i, a)) s a -> (i, a)
s
s ^@?! :: forall s i a.
HasCallStack =>
s -> IndexedGetting i (Endo (i, a)) s a -> (i, a)
^@?! IndexedGetting i (Endo (i, a)) s a
l = IndexedGetting i (Endo (i, a)) s a
-> (i -> a -> (i, a) -> (i, a)) -> (i, a) -> s -> (i, a)
forall i r s a.
IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
ifoldrOf IndexedGetting i (Endo (i, a)) s a
l (\i
i a
x (i, a)
_ -> (i
i,a
x)) (String -> (i, a)
forall a. HasCallStack => String -> a
error String
"(^@?!): empty Fold") s
s
{-# INLINE (^@?!) #-}
elemIndexOf :: Eq a => IndexedGetting i (First i) s a -> a -> s -> Maybe i
elemIndexOf :: forall a i s.
Eq a =>
IndexedGetting i (First i) s a -> a -> s -> Maybe i
elemIndexOf IndexedGetting i (First i) s a
l a
a = IndexedGetting i (First i) s a -> (a -> Bool) -> s -> Maybe i
forall i s a.
IndexedGetting i (First i) s a -> (a -> Bool) -> s -> Maybe i
findIndexOf IndexedGetting i (First i) s a
l (a
a a -> a -> Bool
forall a. Eq a => a -> a -> Bool
==)
{-# INLINE elemIndexOf #-}
elemIndicesOf :: Eq a => IndexedGetting i (Endo [i]) s a -> a -> s -> [i]
elemIndicesOf :: forall a i s.
Eq a =>
IndexedGetting i (Endo [i]) s a -> a -> s -> [i]
elemIndicesOf IndexedGetting i (Endo [i]) s a
l a
a = IndexedGetting i (Endo [i]) s a -> (a -> Bool) -> s -> [i]
forall i s a.
IndexedGetting i (Endo [i]) s a -> (a -> Bool) -> s -> [i]
findIndicesOf IndexedGetting i (Endo [i]) s a
l (a
a a -> a -> Bool
forall a. Eq a => a -> a -> Bool
==)
{-# INLINE elemIndicesOf #-}
findIndexOf :: IndexedGetting i (First i) s a -> (a -> Bool) -> s -> Maybe i
findIndexOf :: forall i s a.
IndexedGetting i (First i) s a -> (a -> Bool) -> s -> Maybe i
findIndexOf IndexedGetting i (First i) s a
l a -> Bool
p = Getting (First i) s i -> s -> Maybe i
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (IndexedGetting i (First i) s a
l IndexedGetting i (First i) s a
-> ((i -> Const (First i) i) -> Indexed i a (Const (First i) a))
-> Getting (First i) s i
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> Optic' (Indexed i) (Const (First i)) a a
forall (p :: * -> * -> *) (f :: * -> *) a.
(Choice p, Applicative f) =>
(a -> Bool) -> Optic' p f a a
filtered a -> Bool
p Optic' (Indexed i) (Const (First i)) a a
-> ((i -> Const (First i) i) -> Indexed i a (Const (First i) a))
-> (i -> Const (First i) i)
-> Indexed i a (Const (First i) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (i -> Const (First i) i) -> Indexed i a (Const (First i) a)
forall i (p :: * -> * -> *) (f :: * -> *) s.
(Indexable i p, Contravariant f, Functor f) =>
p i (f i) -> Indexed i s (f s)
asIndex)
{-# INLINE findIndexOf #-}
findIndicesOf :: IndexedGetting i (Endo [i]) s a -> (a -> Bool) -> s -> [i]
findIndicesOf :: forall i s a.
IndexedGetting i (Endo [i]) s a -> (a -> Bool) -> s -> [i]
findIndicesOf IndexedGetting i (Endo [i]) s a
l a -> Bool
p = Getting (Endo [i]) s i -> s -> [i]
forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf (IndexedGetting i (Endo [i]) s a
l IndexedGetting i (Endo [i]) s a
-> ((i -> Const (Endo [i]) i) -> Indexed i a (Const (Endo [i]) a))
-> Getting (Endo [i]) s i
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> Optic' (Indexed i) (Const (Endo [i])) a a
forall (p :: * -> * -> *) (f :: * -> *) a.
(Choice p, Applicative f) =>
(a -> Bool) -> Optic' p f a a
filtered a -> Bool
p Optic' (Indexed i) (Const (Endo [i])) a a
-> ((i -> Const (Endo [i]) i) -> Indexed i a (Const (Endo [i]) a))
-> (i -> Const (Endo [i]) i)
-> Indexed i a (Const (Endo [i]) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (i -> Const (Endo [i]) i) -> Indexed i a (Const (Endo [i]) a)
forall i (p :: * -> * -> *) (f :: * -> *) s.
(Indexable i p, Contravariant f, Functor f) =>
p i (f i) -> Indexed i s (f s)
asIndex)
{-# INLINE findIndicesOf #-}
ifiltered :: (Indexable i p, Applicative f) => (i -> a -> Bool) -> Optical' p (Indexed i) f a a
ifiltered :: forall i (p :: * -> * -> *) (f :: * -> *) a.
(Indexable i p, Applicative f) =>
(i -> a -> Bool) -> Optical' p (Indexed i) f a a
ifiltered i -> a -> Bool
p p a (f a)
f = (i -> a -> f a) -> Indexed i a (f a)
forall i a b. (i -> a -> b) -> Indexed i a b
Indexed ((i -> a -> f a) -> Indexed i a (f a))
-> (i -> a -> f a) -> Indexed i a (f a)
forall a b. (a -> b) -> a -> b
$ \i
i a
a -> if i -> a -> Bool
p i
i a
a then p a (f a) -> i -> a -> f a
forall a b. p a b -> i -> a -> b
forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p a (f a)
f i
i a
a else a -> f a
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a
{-# INLINE ifiltered #-}
itakingWhile :: (Indexable i p, Profunctor q, Contravariant f, Applicative f)
=> (i -> a -> Bool)
-> Optical' (Indexed i) q (Const (Endo (f s))) s a
-> Optical' p q f s a
itakingWhile :: forall i (p :: * -> * -> *) (q :: * -> * -> *) (f :: * -> *) a s.
(Indexable i p, Profunctor q, Contravariant f, Applicative f) =>
(i -> a -> Bool)
-> Optical' (Indexed i) q (Const (Endo (f s))) s a
-> Optical' p q f s a
itakingWhile i -> a -> Bool
p Optical' (Indexed i) q (Const (Endo (f s))) s a
l p a (f a)
f = ((Endo (f s) -> f s -> f s) -> f s -> Endo (f s) -> f s
forall a b c. (a -> b -> c) -> b -> a -> c
flip Endo (f s) -> f s -> f s
forall a. Endo a -> a -> a
appEndo f s
forall (f :: * -> *) a. (Contravariant f, Applicative f) => f a
noEffect (Endo (f s) -> f s)
-> (Const (Endo (f s)) s -> Endo (f s))
-> Const (Endo (f s)) s
-> f s
forall a b c (q :: * -> * -> *).
Coercible b a =>
(b -> c) -> q a b -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# Const (Endo (f s)) s -> Endo (f s)
forall {k} a (b :: k). Const a b -> a
getConst) (Const (Endo (f s)) s -> f s)
-> q s (Const (Endo (f s)) s) -> q s (f s)
forall b c a. (b -> c) -> q a b -> q a c
forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
`rmap` Optical' (Indexed i) q (Const (Endo (f s))) s a
l Indexed i a (Const (Endo (f s)) a)
forall {b} {b}. Indexed i a (Const (Endo (f b)) b)
g where
g :: Indexed i a (Const (Endo (f b)) b)
g = (i -> a -> Const (Endo (f b)) b)
-> Indexed i a (Const (Endo (f b)) b)
forall i a b. (i -> a -> b) -> Indexed i a b
Indexed ((i -> a -> Const (Endo (f b)) b)
-> Indexed i a (Const (Endo (f b)) b))
-> (i -> a -> Const (Endo (f b)) b)
-> Indexed i a (Const (Endo (f b)) b)
forall a b. (a -> b) -> a -> b
$ \i
i a
a -> Endo (f b) -> Const (Endo (f b)) b
forall {k} a (b :: k). a -> Const a b
Const (Endo (f b) -> Const (Endo (f b)) b)
-> ((f b -> f b) -> Endo (f b))
-> (f b -> f b)
-> Const (Endo (f b)) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (f b -> f b) -> Endo (f b)
forall a. (a -> a) -> Endo a
Endo ((f b -> f b) -> Const (Endo (f b)) b)
-> (f b -> f b) -> Const (Endo (f b)) b
forall a b. (a -> b) -> a -> b
$ if i -> a -> Bool
p i
i a
a then (p a (f a) -> i -> a -> f a
forall a b. p a b -> i -> a -> b
forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p a (f a)
f i
i a
a f a -> f b -> f b
forall a b. f a -> f b -> f b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>) else f b -> f b -> f b
forall a b. a -> b -> a
const f b
forall (f :: * -> *) a. (Contravariant f, Applicative f) => f a
noEffect
{-# INLINE itakingWhile #-}
idroppingWhile :: (Indexable i p, Profunctor q, Applicative f)
=> (i -> a -> Bool)
-> Optical (Indexed i) q (Compose (State Bool) f) s t a a
-> Optical p q f s t a a
idroppingWhile :: forall i (p :: * -> * -> *) (q :: * -> * -> *) (f :: * -> *) a s t.
(Indexable i p, Profunctor q, Applicative f) =>
(i -> a -> Bool)
-> Optical (Indexed i) q (Compose (State Bool) f) s t a a
-> Optical p q f s t a a
idroppingWhile i -> a -> Bool
p Optical (Indexed i) q (Compose (State Bool) f) s t a a
l p a (f a)
f = ((State Bool (f t) -> Bool -> f t)
-> Bool -> State Bool (f t) -> f t
forall a b c. (a -> b -> c) -> b -> a -> c
flip State Bool (f t) -> Bool -> f t
forall s a. State s a -> s -> a
evalState Bool
True (State Bool (f t) -> f t)
-> (Compose (State Bool) f t -> State Bool (f t))
-> Compose (State Bool) f t
-> f t
forall a b c (q :: * -> * -> *).
Coercible b a =>
(b -> c) -> q a b -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible b a) =>
p b c -> q a b -> p a c
.# Compose (State Bool) f t -> State Bool (f t)
forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose) (Compose (State Bool) f t -> f t)
-> q s (Compose (State Bool) f t) -> q s (f t)
forall b c a. (b -> c) -> q a b -> q a c
forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
`rmap` Optical (Indexed i) q (Compose (State Bool) f) s t a a
l Indexed i a (Compose (State Bool) f a)
g where
g :: Indexed i a (Compose (State Bool) f a)
g = (i -> a -> Compose (State Bool) f a)
-> Indexed i a (Compose (State Bool) f a)
forall i a b. (i -> a -> b) -> Indexed i a b
Indexed ((i -> a -> Compose (State Bool) f a)
-> Indexed i a (Compose (State Bool) f a))
-> (i -> a -> Compose (State Bool) f a)
-> Indexed i a (Compose (State Bool) f a)
forall a b. (a -> b) -> a -> b
$ \ i
i a
a -> State Bool (f a) -> Compose (State Bool) f a
forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (State Bool (f a) -> Compose (State Bool) f a)
-> State Bool (f a) -> Compose (State Bool) f a
forall a b. (a -> b) -> a -> b
$ (Bool -> (f a, Bool)) -> State Bool (f a)
forall a. (Bool -> (a, Bool)) -> State Bool a
forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
state ((Bool -> (f a, Bool)) -> State Bool (f a))
-> (Bool -> (f a, Bool)) -> State Bool (f a)
forall a b. (a -> b) -> a -> b
$ \Bool
b -> let
b' :: Bool
b' = Bool
b Bool -> Bool -> Bool
&& i -> a -> Bool
p i
i a
a
in (if Bool
b' then a -> f a
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a else p a (f a) -> i -> a -> f a
forall a b. p a b -> i -> a -> b
forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p a (f a)
f i
i a
a, Bool
b')
{-# INLINE idroppingWhile #-}
skip :: a -> ()
skip :: forall a. a -> ()
skip a
_ = ()
{-# INLINE skip #-}
foldByOf :: Fold s a -> (a -> a -> a) -> a -> s -> a
foldByOf :: forall s a. Fold s a -> (a -> a -> a) -> a -> s -> a
foldByOf Fold s a
l a -> a -> a
f a
z = (a -> a -> a)
-> a
-> (forall s.
Reifies s (ReifiedMonoid a) =>
s -> ReflectedMonoid a s)
-> s
-> a
forall a t.
(a -> a -> a)
-> a
-> (forall s.
Reifies s (ReifiedMonoid a) =>
t -> ReflectedMonoid a s)
-> t
-> a
reifyMonoid a -> a -> a
f a
z (Getting (ReflectedMonoid a s) s a
-> (a -> ReflectedMonoid a s) -> s -> ReflectedMonoid a s
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (ReflectedMonoid a s) s a
Fold s a
l a -> ReflectedMonoid a s
forall {k} a (s :: k). a -> ReflectedMonoid a s
ReflectedMonoid)
foldMapByOf :: Fold s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r
foldMapByOf :: forall s a r. Fold s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r
foldMapByOf Fold s a
l r -> r -> r
f r
z a -> r
g = (r -> r -> r)
-> r
-> (forall s.
Reifies s (ReifiedMonoid r) =>
s -> ReflectedMonoid r s)
-> s
-> r
forall a t.
(a -> a -> a)
-> a
-> (forall s.
Reifies s (ReifiedMonoid a) =>
t -> ReflectedMonoid a s)
-> t
-> a
reifyMonoid r -> r -> r
f r
z (Getting (ReflectedMonoid r s) s a
-> (a -> ReflectedMonoid r s) -> s -> ReflectedMonoid r s
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting (ReflectedMonoid r s) s a
Fold s a
l (r -> ReflectedMonoid r s
forall {k} a (s :: k). a -> ReflectedMonoid a s
ReflectedMonoid (r -> ReflectedMonoid r s) -> (a -> r) -> a -> ReflectedMonoid r s
forall a b c (q :: * -> * -> *).
Coercible c b =>
q b c -> (a -> b) -> a -> c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> r
g))