{-# LANGUAGE CPP #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE MultiParamTypeClasses #-}
#if __GLASGOW_HASKELL__ >= 706
{-# LANGUAGE PolyKinds #-}
#endif
#if __GLASGOW_HASKELL__ < 710
{-# LANGUAGE OverlappingInstances #-}
#define OVERLAPPING_PRAGMA
#else
#define OVERLAPPING_PRAGMA {-# OVERLAPPING #-}
#endif
#ifdef TRUSTWORTHY
{-# LANGUAGE Trustworthy #-}
#endif
#if __GLASGOW_HASKELL__ >= 800
{-# OPTIONS_GHC -Wno-trustworthy-safe #-}
#endif
#ifndef MIN_VERSION_template_haskell
#define MIN_VERSION_template_haskell(x,y,z) 1
#endif
#ifndef MIN_VERSION_free
#define MIN_VERSION_free(x,y,z) 1
#endif
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(x,y,z) 1
#endif
module Control.Lens.Plated
(
Plated(..)
, children
, rewrite, rewriteOf, rewriteOn, rewriteOnOf
, rewriteM, rewriteMOf, rewriteMOn, rewriteMOnOf
, universe, universeOf, universeOn, universeOnOf
, cosmos, cosmosOf, cosmosOn, cosmosOnOf
, transform, transformOf, transformOn, transformOnOf
, transformM, transformMOf, transformMOn, transformMOnOf
, contexts, contextsOf, contextsOn, contextsOnOf
, holes, holesOn, holesOnOf
, para, paraOf
, (...), deep
, composOpFold
, parts
, gplate
, gplate1
, GPlated
, GPlated1
)
where
import Control.Applicative
import Control.Comonad.Cofree
import qualified Control.Comonad.Trans.Cofree as CoTrans
import Control.Lens.Fold
import Control.Lens.Getter
import Control.Lens.Indexed
import Control.Lens.Internal.Context
import Control.Lens.Type
import Control.Lens.Setter
import Control.Lens.Traversal
import Control.Monad.Free as Monad
import Control.Monad.Free.Church as Church
import Control.Monad.Trans.Free as Trans
#if !(MIN_VERSION_free(4,6,0))
import Control.MonadPlus.Free as MonadPlus
#endif
import qualified Language.Haskell.TH as TH
import Data.Data
import Data.Data.Lens
import Data.Monoid
import Data.Tree
import GHC.Generics
#ifdef HLINT
{-# ANN module "HLint: ignore Reduce duplication" #-}
#endif
class Plated a where
plate :: Traversal' a a
default plate :: Data a => Traversal' a a
plate = (a -> f a) -> a -> f a
forall a. Data a => Traversal' a a
uniplate
instance Plated [a] where
plate :: ([a] -> f [a]) -> [a] -> f [a]
plate f :: [a] -> f [a]
f (x :: a
x:xs :: [a]
xs) = (a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:) ([a] -> [a]) -> f [a] -> f [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a] -> f [a]
f [a]
xs
plate _ [] = [a] -> f [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
instance Traversable f => Plated (Monad.Free f a) where
plate :: (Free f a -> f (Free f a)) -> Free f a -> f (Free f a)
plate f :: Free f a -> f (Free f a)
f (Monad.Free as :: f (Free f a)
as) = f (Free f a) -> Free f a
forall (f :: * -> *) a. f (Free f a) -> Free f a
Monad.Free (f (Free f a) -> Free f a) -> f (f (Free f a)) -> f (Free f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Free f a -> f (Free f a)) -> f (Free f a) -> f (f (Free f a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Free f a -> f (Free f a)
f f (Free f a)
as
plate _ x :: Free f a
x = Free f a -> f (Free f a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Free f a
x
instance (Traversable f, Traversable m) => Plated (Trans.FreeT f m a) where
plate :: (FreeT f m a -> f (FreeT f m a)) -> FreeT f m a -> f (FreeT f m a)
plate f :: FreeT f m a -> f (FreeT f m a)
f (Trans.FreeT xs :: m (FreeF f a (FreeT f m a))
xs) = m (FreeF f a (FreeT f m a)) -> FreeT f m a
forall (f :: * -> *) (m :: * -> *) a.
m (FreeF f a (FreeT f m a)) -> FreeT f m a
Trans.FreeT (m (FreeF f a (FreeT f m a)) -> FreeT f m a)
-> f (m (FreeF f a (FreeT f m a))) -> f (FreeT f m a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (FreeF f a (FreeT f m a) -> f (FreeF f a (FreeT f m a)))
-> m (FreeF f a (FreeT f m a)) -> f (m (FreeF f a (FreeT f m a)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((FreeT f m a -> f (FreeT f m a))
-> FreeF f a (FreeT f m a) -> f (FreeF f a (FreeT f m a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse FreeT f m a -> f (FreeT f m a)
f) m (FreeF f a (FreeT f m a))
xs
#if !(MIN_VERSION_free(4,6,0))
instance Traversable f => Plated (MonadPlus.Free f a) where
plate f (MonadPlus.Free as) = MonadPlus.Free <$> traverse f as
plate f (MonadPlus.Plus as) = MonadPlus.Plus <$> traverse f as
plate _ x = pure x
#endif
instance Traversable f => Plated (Church.F f a) where
plate :: (F f a -> f (F f a)) -> F f a -> f (F f a)
plate f :: F f a -> f (F f a)
f = (Free f a -> F f a) -> f (Free f a) -> f (F f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Free f a -> F f a
forall (f :: * -> *) a. Functor f => Free f a -> F f a
Church.toF (f (Free f a) -> f (F f a))
-> (F f a -> f (Free f a)) -> F f a -> f (F f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Free f a -> f (Free f a)) -> Free f a -> f (Free f a)
forall a. Plated a => Traversal' a a
plate ((F f a -> Free f a) -> f (F f a) -> f (Free f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap F f a -> Free f a
forall (f :: * -> *) (m :: * -> *) a. MonadFree f m => F f a -> m a
Church.fromF (f (F f a) -> f (Free f a))
-> (Free f a -> f (F f a)) -> Free f a -> f (Free f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. F f a -> f (F f a)
f (F f a -> f (F f a))
-> (Free f a -> F f a) -> Free f a -> f (F f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Free f a -> F f a
forall (f :: * -> *) a. Functor f => Free f a -> F f a
Church.toF) (Free f a -> f (Free f a))
-> (F f a -> Free f a) -> F f a -> f (Free f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. F f a -> Free f a
forall (f :: * -> *) (m :: * -> *) a. MonadFree f m => F f a -> m a
Church.fromF
instance (Traversable f, Traversable w) => Plated (CoTrans.CofreeT f w a) where
plate :: (CofreeT f w a -> f (CofreeT f w a))
-> CofreeT f w a -> f (CofreeT f w a)
plate f :: CofreeT f w a -> f (CofreeT f w a)
f (CoTrans.CofreeT xs :: w (CofreeF f a (CofreeT f w a))
xs) = w (CofreeF f a (CofreeT f w a)) -> CofreeT f w a
forall (f :: * -> *) (w :: * -> *) a.
w (CofreeF f a (CofreeT f w a)) -> CofreeT f w a
CoTrans.CofreeT (w (CofreeF f a (CofreeT f w a)) -> CofreeT f w a)
-> f (w (CofreeF f a (CofreeT f w a))) -> f (CofreeT f w a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (CofreeF f a (CofreeT f w a) -> f (CofreeF f a (CofreeT f w a)))
-> w (CofreeF f a (CofreeT f w a))
-> f (w (CofreeF f a (CofreeT f w a)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((CofreeT f w a -> f (CofreeT f w a))
-> CofreeF f a (CofreeT f w a) -> f (CofreeF f a (CofreeT f w a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse CofreeT f w a -> f (CofreeT f w a)
f) w (CofreeF f a (CofreeT f w a))
xs
instance Traversable f => Plated (Cofree f a) where
plate :: (Cofree f a -> f (Cofree f a)) -> Cofree f a -> f (Cofree f a)
plate f :: Cofree f a -> f (Cofree f a)
f (a :: a
a :< as :: f (Cofree f a)
as) = a -> f (Cofree f a) -> Cofree f a
forall (f :: * -> *) a. a -> f (Cofree f a) -> Cofree f a
(:<) a
a (f (Cofree f a) -> Cofree f a)
-> f (f (Cofree f a)) -> f (Cofree f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Cofree f a -> f (Cofree f a))
-> f (Cofree f a) -> f (f (Cofree f a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Cofree f a -> f (Cofree f a)
f f (Cofree f a)
as
instance Plated (Tree a) where
plate :: (Tree a -> f (Tree a)) -> Tree a -> f (Tree a)
plate f :: Tree a -> f (Tree a)
f (Node a :: a
a as :: Forest a
as) = a -> Forest a -> Tree a
forall a. a -> Forest a -> Tree a
Node a
a (Forest a -> Tree a) -> f (Forest a) -> f (Tree a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Tree a -> f (Tree a)) -> Forest a -> f (Forest a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Tree a -> f (Tree a)
f Forest a
as
instance Plated TH.Exp
instance Plated TH.Dec
instance Plated TH.Con
instance Plated TH.Type
#if !(MIN_VERSION_template_haskell(2,8,0))
instance Plated TH.Kind
#endif
instance Plated TH.Stmt
instance Plated TH.Pat
infixr 9 ...
(...) :: (Applicative f, Plated c) => LensLike f s t c c -> Over p f c c a b -> Over p f s t a b
l :: LensLike f s t c c
l ... :: LensLike f s t c c -> Over p f c c a b -> Over p f s t a b
... m :: Over p f c c a b
m = LensLike f s t c c
l LensLike f s t c c -> Over p f c c a b -> Over p f s t a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (c -> f c) -> c -> f c
forall a. Plated a => Traversal' a a
plate ((c -> f c) -> c -> f c) -> Over p f c c a b -> Over p f c c a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Over p f c c a b
m
{-# INLINE (...) #-}
deep :: (Conjoined p, Applicative f, Plated s) => Traversing p f s s a b -> Over p f s s a b
deep :: Traversing p f s s a b -> Over p f s s a b
deep = LensLike f s s s s -> Traversing p f s s a b -> Over p f s s a b
forall (p :: * -> * -> *) (f :: * -> *) s t a b.
(Conjoined p, Applicative f) =>
LensLike f s t s t -> Traversing p f s t a b -> Over p f s t a b
deepOf LensLike f s s s s
forall a. Plated a => Traversal' a a
plate
children :: Plated a => a -> [a]
children :: a -> [a]
children = Getting (Endo [a]) a a -> a -> [a]
forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Getting (Endo [a]) a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE children #-}
rewrite :: Plated a => (a -> Maybe a) -> a -> a
rewrite :: (a -> Maybe a) -> a -> a
rewrite = ASetter a a a a -> (a -> Maybe a) -> a -> a
forall a b. ASetter a b a b -> (b -> Maybe a) -> a -> b
rewriteOf ASetter a a a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE rewrite #-}
rewriteOf :: ASetter a b a b -> (b -> Maybe a) -> a -> b
rewriteOf :: ASetter a b a b -> (b -> Maybe a) -> a -> b
rewriteOf l :: ASetter a b a b
l f :: b -> Maybe a
f = a -> b
go where
go :: a -> b
go = ASetter a b a b -> (b -> b) -> a -> b
forall a b. ASetter a b a b -> (b -> b) -> a -> b
transformOf ASetter a b a b
l (\x :: b
x -> b -> (a -> b) -> Maybe a -> b
forall b a. b -> (a -> b) -> Maybe a -> b
maybe b
x a -> b
go (b -> Maybe a
f b
x))
{-# INLINE rewriteOf #-}
rewriteOn :: Plated a => ASetter s t a a -> (a -> Maybe a) -> s -> t
rewriteOn :: ASetter s t a a -> (a -> Maybe a) -> s -> t
rewriteOn b :: ASetter s t a a
b = ASetter s t a a -> (a -> a) -> s -> t
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter s t a a
b ((a -> a) -> s -> t)
-> ((a -> Maybe a) -> a -> a) -> (a -> Maybe a) -> s -> t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Maybe a) -> a -> a
forall a. Plated a => (a -> Maybe a) -> a -> a
rewrite
{-# INLINE rewriteOn #-}
rewriteOnOf :: ASetter s t a b -> ASetter a b a b -> (b -> Maybe a) -> s -> t
rewriteOnOf :: ASetter s t a b -> ASetter a b a b -> (b -> Maybe a) -> s -> t
rewriteOnOf b :: ASetter s t a b
b l :: ASetter a b a b
l = ASetter s t a b -> (a -> b) -> s -> t
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter s t a b
b ((a -> b) -> s -> t)
-> ((b -> Maybe a) -> a -> b) -> (b -> Maybe a) -> s -> t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ASetter a b a b -> (b -> Maybe a) -> a -> b
forall a b. ASetter a b a b -> (b -> Maybe a) -> a -> b
rewriteOf ASetter a b a b
l
{-# INLINE rewriteOnOf #-}
rewriteM :: (Monad m, Plated a) => (a -> m (Maybe a)) -> a -> m a
rewriteM :: (a -> m (Maybe a)) -> a -> m a
rewriteM = LensLike (WrappedMonad m) a a a a -> (a -> m (Maybe a)) -> a -> m a
forall (m :: * -> *) a b.
Monad m =>
LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> a -> m b
rewriteMOf LensLike (WrappedMonad m) a a a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE rewriteM #-}
rewriteMOf :: Monad m => LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> a -> m b
rewriteMOf :: LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> a -> m b
rewriteMOf l :: LensLike (WrappedMonad m) a b a b
l f :: b -> m (Maybe a)
f = a -> m b
go where
go :: a -> m b
go = LensLike (WrappedMonad m) a b a b -> (b -> m b) -> a -> m b
forall (m :: * -> *) a b.
Monad m =>
LensLike (WrappedMonad m) a b a b -> (b -> m b) -> a -> m b
transformMOf LensLike (WrappedMonad m) a b a b
l (\x :: b
x -> b -> m (Maybe a)
f b
x m (Maybe a) -> (Maybe a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= m b -> (a -> m b) -> Maybe a -> m b
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (b -> m b
forall (m :: * -> *) a. Monad m => a -> m a
return b
x) a -> m b
go)
{-# INLINE rewriteMOf #-}
rewriteMOn :: (Monad m, Plated a) => LensLike (WrappedMonad m) s t a a -> (a -> m (Maybe a)) -> s -> m t
rewriteMOn :: LensLike (WrappedMonad m) s t a a -> (a -> m (Maybe a)) -> s -> m t
rewriteMOn b :: LensLike (WrappedMonad m) s t a a
b = LensLike (WrappedMonad m) s t a a -> (a -> m a) -> s -> m t
forall (m :: * -> *) s t a b.
LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t
mapMOf LensLike (WrappedMonad m) s t a a
b ((a -> m a) -> s -> m t)
-> ((a -> m (Maybe a)) -> a -> m a)
-> (a -> m (Maybe a))
-> s
-> m t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> m (Maybe a)) -> a -> m a
forall (m :: * -> *) a.
(Monad m, Plated a) =>
(a -> m (Maybe a)) -> a -> m a
rewriteM
{-# INLINE rewriteMOn #-}
rewriteMOnOf :: Monad m => LensLike (WrappedMonad m) s t a b -> LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> s -> m t
rewriteMOnOf :: LensLike (WrappedMonad m) s t a b
-> LensLike (WrappedMonad m) a b a b
-> (b -> m (Maybe a))
-> s
-> m t
rewriteMOnOf b :: LensLike (WrappedMonad m) s t a b
b l :: LensLike (WrappedMonad m) a b a b
l = LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t
forall (m :: * -> *) s t a b.
LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t
mapMOf LensLike (WrappedMonad m) s t a b
b ((a -> m b) -> s -> m t)
-> ((b -> m (Maybe a)) -> a -> m b)
-> (b -> m (Maybe a))
-> s
-> m t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> a -> m b
forall (m :: * -> *) a b.
Monad m =>
LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> a -> m b
rewriteMOf LensLike (WrappedMonad m) a b a b
l
{-# INLINE rewriteMOnOf #-}
universe :: Plated a => a -> [a]
universe :: a -> [a]
universe = Getting [a] a a -> a -> [a]
forall a. Getting [a] a a -> a -> [a]
universeOf Getting [a] a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE universe #-}
universeOf :: Getting [a] a a -> a -> [a]
universeOf :: Getting [a] a a -> a -> [a]
universeOf l :: Getting [a] a a
l = a -> [a]
go where
go :: a -> [a]
go a :: a
a = a
a a -> [a] -> [a]
forall a. a -> [a] -> [a]
: Getting [a] a a -> (a -> [a]) -> a -> [a]
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting [a] a a
l a -> [a]
go a
a
{-# INLINE universeOf #-}
universeOn :: Plated a => Getting [a] s a -> s -> [a]
universeOn :: Getting [a] s a -> s -> [a]
universeOn b :: Getting [a] s a
b = Getting [a] s a -> Getting [a] a a -> s -> [a]
forall a s. Getting [a] s a -> Getting [a] a a -> s -> [a]
universeOnOf Getting [a] s a
b Getting [a] a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE universeOn #-}
universeOnOf :: Getting [a] s a -> Getting [a] a a -> s -> [a]
universeOnOf :: Getting [a] s a -> Getting [a] a a -> s -> [a]
universeOnOf b :: Getting [a] s a
b = Getting [a] s a -> (a -> [a]) -> s -> [a]
forall r s a. Getting r s a -> (a -> r) -> s -> r
foldMapOf Getting [a] s a
b ((a -> [a]) -> s -> [a])
-> (Getting [a] a a -> a -> [a]) -> Getting [a] a a -> s -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting [a] a a -> a -> [a]
forall a. Getting [a] a a -> a -> [a]
universeOf
{-# INLINE universeOnOf #-}
cosmos :: Plated a => Fold a a
cosmos :: Fold a a
cosmos = LensLike' f a a -> LensLike' f a a
forall (f :: * -> *) a.
(Applicative f, Contravariant f) =>
LensLike' f a a -> LensLike' f a a
cosmosOf LensLike' f a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE cosmos #-}
cosmosOf :: (Applicative f, Contravariant f) => LensLike' f a a -> LensLike' f a a
cosmosOf :: LensLike' f a a -> LensLike' f a a
cosmosOf d :: LensLike' f a a
d f :: a -> f a
f s :: a
s = a -> f a
f a
s f a -> f a -> f a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LensLike' f a a
d (LensLike' f a a -> LensLike' f a a
forall (f :: * -> *) a.
(Applicative f, Contravariant f) =>
LensLike' f a a -> LensLike' f a a
cosmosOf LensLike' f a a
d a -> f a
f) a
s
{-# INLINE cosmosOf #-}
cosmosOn :: (Applicative f, Contravariant f, Plated a) => LensLike' f s a -> LensLike' f s a
cosmosOn :: LensLike' f s a -> LensLike' f s a
cosmosOn d :: LensLike' f s a
d = LensLike' f s a -> LensLike' f a a -> LensLike' f s a
forall (f :: * -> *) s a.
(Applicative f, Contravariant f) =>
LensLike' f s a -> LensLike' f a a -> LensLike' f s a
cosmosOnOf LensLike' f s a
d LensLike' f a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE cosmosOn #-}
cosmosOnOf :: (Applicative f, Contravariant f) => LensLike' f s a -> LensLike' f a a -> LensLike' f s a
cosmosOnOf :: LensLike' f s a -> LensLike' f a a -> LensLike' f s a
cosmosOnOf d :: LensLike' f s a
d p :: LensLike' f a a
p = LensLike' f s a
d LensLike' f s a -> LensLike' f a a -> LensLike' f s a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike' f a a -> LensLike' f a a
forall (f :: * -> *) a.
(Applicative f, Contravariant f) =>
LensLike' f a a -> LensLike' f a a
cosmosOf LensLike' f a a
p
{-# INLINE cosmosOnOf #-}
transform :: Plated a => (a -> a) -> a -> a
transform :: (a -> a) -> a -> a
transform = ASetter a a a a -> (a -> a) -> a -> a
forall a b. ASetter a b a b -> (b -> b) -> a -> b
transformOf ASetter a a a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE transform #-}
transformOn :: Plated a => ASetter s t a a -> (a -> a) -> s -> t
transformOn :: ASetter s t a a -> (a -> a) -> s -> t
transformOn b :: ASetter s t a a
b = ASetter s t a a -> (a -> a) -> s -> t
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter s t a a
b ((a -> a) -> s -> t) -> ((a -> a) -> a -> a) -> (a -> a) -> s -> t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a) -> a -> a
forall a. Plated a => (a -> a) -> a -> a
transform
{-# INLINE transformOn #-}
transformOf :: ASetter a b a b -> (b -> b) -> a -> b
transformOf :: ASetter a b a b -> (b -> b) -> a -> b
transformOf l :: ASetter a b a b
l f :: b -> b
f = a -> b
go where
go :: a -> b
go = b -> b
f (b -> b) -> (a -> b) -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ASetter a b a b -> (a -> b) -> a -> b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter a b a b
l a -> b
go
{-# INLINE transformOf #-}
transformOnOf :: ASetter s t a b -> ASetter a b a b -> (b -> b) -> s -> t
transformOnOf :: ASetter s t a b -> ASetter a b a b -> (b -> b) -> s -> t
transformOnOf b :: ASetter s t a b
b l :: ASetter a b a b
l = ASetter s t a b -> (a -> b) -> s -> t
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter s t a b
b ((a -> b) -> s -> t) -> ((b -> b) -> a -> b) -> (b -> b) -> s -> t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ASetter a b a b -> (b -> b) -> a -> b
forall a b. ASetter a b a b -> (b -> b) -> a -> b
transformOf ASetter a b a b
l
{-# INLINE transformOnOf #-}
transformM :: (Monad m, Plated a) => (a -> m a) -> a -> m a
transformM :: (a -> m a) -> a -> m a
transformM = LensLike (WrappedMonad m) a a a a -> (a -> m a) -> a -> m a
forall (m :: * -> *) a b.
Monad m =>
LensLike (WrappedMonad m) a b a b -> (b -> m b) -> a -> m b
transformMOf LensLike (WrappedMonad m) a a a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE transformM #-}
transformMOn :: (Monad m, Plated a) => LensLike (WrappedMonad m) s t a a -> (a -> m a) -> s -> m t
transformMOn :: LensLike (WrappedMonad m) s t a a -> (a -> m a) -> s -> m t
transformMOn b :: LensLike (WrappedMonad m) s t a a
b = LensLike (WrappedMonad m) s t a a -> (a -> m a) -> s -> m t
forall (m :: * -> *) s t a b.
LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t
mapMOf LensLike (WrappedMonad m) s t a a
b ((a -> m a) -> s -> m t)
-> ((a -> m a) -> a -> m a) -> (a -> m a) -> s -> m t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> m a) -> a -> m a
forall (m :: * -> *) a.
(Monad m, Plated a) =>
(a -> m a) -> a -> m a
transformM
{-# INLINE transformMOn #-}
transformMOf :: Monad m => LensLike (WrappedMonad m) a b a b -> (b -> m b) -> a -> m b
transformMOf :: LensLike (WrappedMonad m) a b a b -> (b -> m b) -> a -> m b
transformMOf l :: LensLike (WrappedMonad m) a b a b
l f :: b -> m b
f = a -> m b
go where
go :: a -> m b
go t :: a
t = LensLike (WrappedMonad m) a b a b -> (a -> m b) -> a -> m b
forall (m :: * -> *) s t a b.
LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t
mapMOf LensLike (WrappedMonad m) a b a b
l a -> m b
go a
t m b -> (b -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= b -> m b
f
{-# INLINE transformMOf #-}
transformMOnOf :: Monad m => LensLike (WrappedMonad m) s t a b -> LensLike (WrappedMonad m) a b a b -> (b -> m b) -> s -> m t
transformMOnOf :: LensLike (WrappedMonad m) s t a b
-> LensLike (WrappedMonad m) a b a b -> (b -> m b) -> s -> m t
transformMOnOf b :: LensLike (WrappedMonad m) s t a b
b l :: LensLike (WrappedMonad m) a b a b
l = LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t
forall (m :: * -> *) s t a b.
LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t
mapMOf LensLike (WrappedMonad m) s t a b
b ((a -> m b) -> s -> m t)
-> ((b -> m b) -> a -> m b) -> (b -> m b) -> s -> m t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike (WrappedMonad m) a b a b -> (b -> m b) -> a -> m b
forall (m :: * -> *) a b.
Monad m =>
LensLike (WrappedMonad m) a b a b -> (b -> m b) -> a -> m b
transformMOf LensLike (WrappedMonad m) a b a b
l
{-# INLINE transformMOnOf #-}
contexts :: Plated a => a -> [Context a a a]
contexts :: a -> [Context a a a]
contexts = ATraversal' a a -> a -> [Context a a a]
forall a. ATraversal' a a -> a -> [Context a a a]
contextsOf ATraversal' a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE contexts #-}
contextsOf :: ATraversal' a a -> a -> [Context a a a]
contextsOf :: ATraversal' a a -> a -> [Context a a a]
contextsOf l :: ATraversal' a a
l x :: a
x = a -> Context a a a
forall (p :: * -> * -> *) (w :: * -> * -> * -> *) a b.
Sellable p w =>
p a (w a b b)
sell a
x Context a a a -> [Context a a a] -> [Context a a a]
forall a. a -> [a] -> [a]
: [Context a a a] -> [Context a a a]
forall t. [Context a a t] -> [Context a a t]
f ((Pretext (->) a a a -> Context a a a)
-> [Pretext (->) a a a] -> [Context a a a]
forall a b. (a -> b) -> [a] -> [b]
map Pretext (->) a a a -> Context a a a
forall (w :: * -> * -> * -> *) a b t.
IndexedComonadStore w =>
w a b t -> Context a b t
context (ATraversal' a a -> a -> [Pretext (->) a a a]
forall (p :: * -> * -> *) a s t.
Conjoined p =>
Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
holesOf ATraversal' a a
l a
x)) where
f :: [Context a a t] -> [Context a a t]
f xs :: [Context a a t]
xs = do
Context ctx :: a -> t
ctx child :: a
child <- [Context a a t]
xs
Context cont :: a -> a
cont y :: a
y <- ATraversal' a a -> a -> [Context a a a]
forall a. ATraversal' a a -> a -> [Context a a a]
contextsOf ATraversal' a a
l a
child
Context a a t -> [Context a a t]
forall (m :: * -> *) a. Monad m => a -> m a
return (Context a a t -> [Context a a t])
-> Context a a t -> [Context a a t]
forall a b. (a -> b) -> a -> b
$ (a -> t) -> a -> Context a a t
forall a b t. (b -> t) -> a -> Context a b t
Context (a -> t
ctx (a -> t) -> (a -> a) -> a -> t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
cont) a
y
{-# INLINE contextsOf #-}
contextsOn :: Plated a => ATraversal s t a a -> s -> [Context a a t]
contextsOn :: ATraversal s t a a -> s -> [Context a a t]
contextsOn b :: ATraversal s t a a
b = ATraversal s t a a -> ATraversal' a a -> s -> [Context a a t]
forall s t a.
ATraversal s t a a -> ATraversal' a a -> s -> [Context a a t]
contextsOnOf ATraversal s t a a
b ATraversal' a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE contextsOn #-}
contextsOnOf :: ATraversal s t a a -> ATraversal' a a -> s -> [Context a a t]
contextsOnOf :: ATraversal s t a a -> ATraversal' a a -> s -> [Context a a t]
contextsOnOf b :: ATraversal s t a a
b l :: ATraversal' a a
l = [Context a a t] -> [Context a a t]
forall t. [Context a a t] -> [Context a a t]
f ([Context a a t] -> [Context a a t])
-> (s -> [Context a a t]) -> s -> [Context a a t]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pretext (->) a a t -> Context a a t)
-> [Pretext (->) a a t] -> [Context a a t]
forall a b. (a -> b) -> [a] -> [b]
map Pretext (->) a a t -> Context a a t
forall (w :: * -> * -> * -> *) a b t.
IndexedComonadStore w =>
w a b t -> Context a b t
context ([Pretext (->) a a t] -> [Context a a t])
-> (s -> [Pretext (->) a a t]) -> s -> [Context a a t]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ATraversal s t a a -> s -> [Pretext (->) a a t]
forall (p :: * -> * -> *) a s t.
Conjoined p =>
Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
holesOf ATraversal s t a a
b where
f :: [Context a a t] -> [Context a a t]
f xs :: [Context a a t]
xs = do
Context ctx :: a -> t
ctx child :: a
child <- [Context a a t]
xs
Context cont :: a -> a
cont y :: a
y <- ATraversal' a a -> a -> [Context a a a]
forall a. ATraversal' a a -> a -> [Context a a a]
contextsOf ATraversal' a a
l a
child
Context a a t -> [Context a a t]
forall (m :: * -> *) a. Monad m => a -> m a
return (Context a a t -> [Context a a t])
-> Context a a t -> [Context a a t]
forall a b. (a -> b) -> a -> b
$ (a -> t) -> a -> Context a a t
forall a b t. (b -> t) -> a -> Context a b t
Context (a -> t
ctx (a -> t) -> (a -> a) -> a -> t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
cont) a
y
{-# INLINE contextsOnOf #-}
holes :: Plated a => a -> [Pretext (->) a a a]
holes :: a -> [Pretext (->) a a a]
holes = Over (->) (Bazaar (->) a a) a a a a -> a -> [Pretext (->) a a a]
forall (p :: * -> * -> *) a s t.
Conjoined p =>
Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
holesOf Over (->) (Bazaar (->) a a) a a a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE holes #-}
holesOn :: Conjoined p => Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
holesOn :: Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
holesOn = Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
forall (p :: * -> * -> *) a s t.
Conjoined p =>
Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
holesOf
{-# INLINE holesOn #-}
holesOnOf :: Conjoined p
=> LensLike (Bazaar p r r) s t a b
-> Over p (Bazaar p r r) a b r r
-> s -> [Pretext p r r t]
holesOnOf :: LensLike (Bazaar p r r) s t a b
-> Over p (Bazaar p r r) a b r r -> s -> [Pretext p r r t]
holesOnOf b :: LensLike (Bazaar p r r) s t a b
b l :: Over p (Bazaar p r r) a b r r
l = Over p (Bazaar p r r) s t r r -> s -> [Pretext p r r t]
forall (p :: * -> * -> *) a s t.
Conjoined p =>
Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
holesOf (LensLike (Bazaar p r r) s t a b
b LensLike (Bazaar p r r) s t a b
-> Over p (Bazaar p r r) a b r r -> Over p (Bazaar p r r) s t r r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Over p (Bazaar p r r) a b r r
l)
{-# INLINE holesOnOf #-}
paraOf :: Getting (Endo [a]) a a -> (a -> [r] -> r) -> a -> r
paraOf :: Getting (Endo [a]) a a -> (a -> [r] -> r) -> a -> r
paraOf l :: Getting (Endo [a]) a a
l f :: a -> [r] -> r
f = a -> r
go where
go :: a -> r
go a :: a
a = a -> [r] -> r
f a
a (a -> r
go (a -> r) -> [a] -> [r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Getting (Endo [a]) a a -> a -> [a]
forall a s. Getting (Endo [a]) s a -> s -> [a]
toListOf Getting (Endo [a]) a a
l a
a)
{-# INLINE paraOf #-}
para :: Plated a => (a -> [r] -> r) -> a -> r
para :: (a -> [r] -> r) -> a -> r
para = Getting (Endo [a]) a a -> (a -> [r] -> r) -> a -> r
forall a r. Getting (Endo [a]) a a -> (a -> [r] -> r) -> a -> r
paraOf Getting (Endo [a]) a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE para #-}
composOpFold :: Plated a => b -> (b -> b -> b) -> (a -> b) -> a -> b
composOpFold :: b -> (b -> b -> b) -> (a -> b) -> a -> b
composOpFold z :: b
z c :: b -> b -> b
c f :: a -> b
f = Getting (Endo b) a a -> (a -> b -> b) -> b -> a -> b
forall r s a. Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
foldrOf Getting (Endo b) a a
forall a. Plated a => Traversal' a a
plate (b -> b -> b
c (b -> b -> b) -> (a -> b) -> a -> b -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f) b
z
{-# INLINE composOpFold #-}
parts :: Plated a => Lens' a [a]
parts :: Lens' a [a]
parts = Traversing (->) f a a a a -> LensLike f a a [a] [a]
forall (f :: * -> *) s t a.
Functor f =>
Traversing (->) f s t a a -> LensLike f s t [a] [a]
partsOf Traversing (->) f a a a a
forall a. Plated a => Traversal' a a
plate
{-# INLINE parts #-}
gplate :: (Generic a, GPlated a (Rep a)) => Traversal' a a
gplate :: Traversal' a a
gplate f :: a -> f a
f x :: a
x = Rep a Any -> a
forall a x. Generic a => Rep a x -> a
GHC.Generics.to (Rep a Any -> a) -> f (Rep a Any) -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f a) -> Rep a Any -> f (Rep a Any)
forall k a (g :: k -> *) (p :: k).
GPlated a g =>
Traversal' (g p) a
gplate' a -> f a
f (a -> Rep a Any
forall a x. Generic a => a -> Rep a x
GHC.Generics.from a
x)
{-# INLINE gplate #-}
class GPlated a g where
gplate' :: Traversal' (g p) a
instance GPlated a f => GPlated a (M1 i c f) where
gplate' :: (a -> f a) -> M1 i c f p -> f (M1 i c f p)
gplate' f :: a -> f a
f (M1 x :: f p
x) = f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (f p -> M1 i c f p) -> f (f p) -> f (M1 i c f p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f a) -> f p -> f (f p)
forall k a (g :: k -> *) (p :: k).
GPlated a g =>
Traversal' (g p) a
gplate' a -> f a
f f p
x
{-# INLINE gplate' #-}
instance (GPlated a f, GPlated a g) => GPlated a (f :+: g) where
gplate' :: (a -> f a) -> (:+:) f g p -> f ((:+:) f g p)
gplate' f :: a -> f a
f (L1 x :: f p
x) = f p -> (:+:) f g p
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (f p -> (:+:) f g p) -> f (f p) -> f ((:+:) f g p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f a) -> f p -> f (f p)
forall k a (g :: k -> *) (p :: k).
GPlated a g =>
Traversal' (g p) a
gplate' a -> f a
f f p
x
gplate' f :: a -> f a
f (R1 x :: g p
x) = g p -> (:+:) f g p
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (g p -> (:+:) f g p) -> f (g p) -> f ((:+:) f g p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f a) -> g p -> f (g p)
forall k a (g :: k -> *) (p :: k).
GPlated a g =>
Traversal' (g p) a
gplate' a -> f a
f g p
x
{-# INLINE gplate' #-}
instance (GPlated a f, GPlated a g) => GPlated a (f :*: g) where
gplate' :: (a -> f a) -> (:*:) f g p -> f ((:*:) f g p)
gplate' f :: a -> f a
f (x :: f p
x :*: y :: g p
y) = f p -> g p -> (:*:) f g p
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(:*:) (f p -> g p -> (:*:) f g p) -> f (f p) -> f (g p -> (:*:) f g p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f a) -> f p -> f (f p)
forall k a (g :: k -> *) (p :: k).
GPlated a g =>
Traversal' (g p) a
gplate' a -> f a
f f p
x f (g p -> (:*:) f g p) -> f (g p) -> f ((:*:) f g p)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> f a) -> g p -> f (g p)
forall k a (g :: k -> *) (p :: k).
GPlated a g =>
Traversal' (g p) a
gplate' a -> f a
f g p
y
{-# INLINE gplate' #-}
instance OVERLAPPING_PRAGMA GPlated a (K1 i a) where
gplate' :: (a -> f a) -> K1 i a p -> f (K1 i a p)
gplate' f :: a -> f a
f (K1 x :: a
x) = a -> K1 i a p
forall k i c (p :: k). c -> K1 i c p
K1 (a -> K1 i a p) -> f a -> f (K1 i a p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
f a
x
{-# INLINE gplate' #-}
instance GPlated a (K1 i b) where
gplate' :: (a -> f a) -> K1 i b p -> f (K1 i b p)
gplate' _ = K1 i b p -> f (K1 i b p)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE gplate' #-}
instance GPlated a U1 where
gplate' :: (a -> f a) -> U1 p -> f (U1 p)
gplate' _ = U1 p -> f (U1 p)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE gplate' #-}
instance GPlated a V1 where
gplate' :: (a -> f a) -> V1 p -> f (V1 p)
gplate' _ v :: V1 p
v = V1 p
v V1 p -> f (V1 p) -> f (V1 p)
forall a b. a -> b -> b
`seq` [Char] -> f (V1 p)
forall a. HasCallStack => [Char] -> a
error "GPlated/V1"
{-# INLINE gplate' #-}
#if MIN_VERSION_base(4,9,0)
instance GPlated a (URec b) where
gplate' :: (a -> f a) -> URec b p -> f (URec b p)
gplate' _ = URec b p -> f (URec b p)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE gplate' #-}
#endif
gplate1 :: (Generic1 f, GPlated1 f (Rep1 f)) => Traversal' (f a) (f a)
gplate1 :: Traversal' (f a) (f a)
gplate1 f :: f a -> f (f a)
f x :: f a
x = Rep1 f a -> f a
forall k (f :: k -> *) (a :: k). Generic1 f => Rep1 f a -> f a
GHC.Generics.to1 (Rep1 f a -> f a) -> f (Rep1 f a) -> f (f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (f a -> f (f a)) -> Rep1 f a -> f (Rep1 f a)
forall k (f :: k -> *) (g :: k -> *) (a :: k).
GPlated1 f g =>
Traversal' (g a) (f a)
gplate1' f a -> f (f a)
f (f a -> Rep1 f a
forall k (f :: k -> *) (a :: k). Generic1 f => f a -> Rep1 f a
GHC.Generics.from1 f a
x)
{-# INLINE gplate1 #-}
class GPlated1 f g where
gplate1' :: Traversal' (g a) (f a)
instance GPlated1 f g => GPlated1 f (M1 i c g) where
gplate1' :: (f a -> f (f a)) -> M1 i c g a -> f (M1 i c g a)
gplate1' f :: f a -> f (f a)
f (M1 x :: g a
x) = g a -> M1 i c g a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (g a -> M1 i c g a) -> f (g a) -> f (M1 i c g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (f a -> f (f a)) -> g a -> f (g a)
forall k (f :: k -> *) (g :: k -> *) (a :: k).
GPlated1 f g =>
Traversal' (g a) (f a)
gplate1' f a -> f (f a)
f g a
x
{-# INLINE gplate1' #-}
instance (GPlated1 f g, GPlated1 f h) => GPlated1 f (g :+: h) where
gplate1' :: (f a -> f (f a)) -> (:+:) g h a -> f ((:+:) g h a)
gplate1' f :: f a -> f (f a)
f (L1 x :: g a
x) = g a -> (:+:) g h a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (g a -> (:+:) g h a) -> f (g a) -> f ((:+:) g h a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (f a -> f (f a)) -> g a -> f (g a)
forall k (f :: k -> *) (g :: k -> *) (a :: k).
GPlated1 f g =>
Traversal' (g a) (f a)
gplate1' f a -> f (f a)
f g a
x
gplate1' f :: f a -> f (f a)
f (R1 x :: h a
x) = h a -> (:+:) g h a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (h a -> (:+:) g h a) -> f (h a) -> f ((:+:) g h a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (f a -> f (f a)) -> h a -> f (h a)
forall k (f :: k -> *) (g :: k -> *) (a :: k).
GPlated1 f g =>
Traversal' (g a) (f a)
gplate1' f a -> f (f a)
f h a
x
{-# INLINE gplate1' #-}
instance (GPlated1 f g, GPlated1 f h) => GPlated1 f (g :*: h) where
gplate1' :: (f a -> f (f a)) -> (:*:) g h a -> f ((:*:) g h a)
gplate1' f :: f a -> f (f a)
f (x :: g a
x :*: y :: h a
y) = g a -> h a -> (:*:) g h a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(:*:) (g a -> h a -> (:*:) g h a) -> f (g a) -> f (h a -> (:*:) g h a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (f a -> f (f a)) -> g a -> f (g a)
forall k (f :: k -> *) (g :: k -> *) (a :: k).
GPlated1 f g =>
Traversal' (g a) (f a)
gplate1' f a -> f (f a)
f g a
x f (h a -> (:*:) g h a) -> f (h a) -> f ((:*:) g h a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (f a -> f (f a)) -> h a -> f (h a)
forall k (f :: k -> *) (g :: k -> *) (a :: k).
GPlated1 f g =>
Traversal' (g a) (f a)
gplate1' f a -> f (f a)
f h a
y
{-# INLINE gplate1' #-}
instance GPlated1 f (K1 i a) where
gplate1' :: (f a -> f (f a)) -> K1 i a a -> f (K1 i a a)
gplate1' _ = K1 i a a -> f (K1 i a a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE gplate1' #-}
instance GPlated1 f Par1 where
gplate1' :: (f a -> f (f a)) -> Par1 a -> f (Par1 a)
gplate1' _ = Par1 a -> f (Par1 a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE gplate1' #-}
instance GPlated1 f U1 where
gplate1' :: (f a -> f (f a)) -> U1 a -> f (U1 a)
gplate1' _ = U1 a -> f (U1 a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE gplate1' #-}
instance GPlated1 f V1 where
gplate1' :: (f a -> f (f a)) -> V1 a -> f (V1 a)
gplate1' _ = V1 a -> f (V1 a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE gplate1' #-}
instance OVERLAPPING_PRAGMA GPlated1 f (Rec1 f) where
gplate1' :: (f a -> f (f a)) -> Rec1 f a -> f (Rec1 f a)
gplate1' f :: f a -> f (f a)
f (Rec1 x :: f a
x) = f a -> Rec1 f a
forall k (f :: k -> *) (p :: k). f p -> Rec1 f p
Rec1 (f a -> Rec1 f a) -> f (f a) -> f (Rec1 f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a -> f (f a)
f f a
x
{-# INLINE gplate1' #-}
instance GPlated1 f (Rec1 g) where
gplate1' :: (f a -> f (f a)) -> Rec1 g a -> f (Rec1 g a)
gplate1' _ = Rec1 g a -> f (Rec1 g a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE gplate1' #-}
instance (Traversable t, GPlated1 f g) => GPlated1 f (t :.: g) where
gplate1' :: (f a -> f (f a)) -> (:.:) t g a -> f ((:.:) t g a)
gplate1' f :: f a -> f (f a)
f (Comp1 x :: t (g a)
x) = t (g a) -> (:.:) t g a
forall k2 k1 (f :: k2 -> *) (g :: k1 -> k2) (p :: k1).
f (g p) -> (:.:) f g p
Comp1 (t (g a) -> (:.:) t g a) -> f (t (g a)) -> f ((:.:) t g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (g a -> f (g a)) -> t (g a) -> f (t (g a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((f a -> f (f a)) -> g a -> f (g a)
forall k (f :: k -> *) (g :: k -> *) (a :: k).
GPlated1 f g =>
Traversal' (g a) (f a)
gplate1' f a -> f (f a)
f) t (g a)
x
{-# INLINE gplate1' #-}
#if MIN_VERSION_base(4,9,0)
instance GPlated1 f (URec a) where
gplate1' :: (f a -> f (f a)) -> URec a a -> f (URec a a)
gplate1' _ = URec a a -> f (URec a a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE gplate1' #-}
#endif