optics-core-0.4.1.1: Optics as an abstract interface: core definitions

Safe Haskell | None
Language | Haskell2010

Optics.Internal.Utils

Description

This module is intended for internal use only, and may change without warning in subsequent releases.

Synopsis

- data Identity' a = Identity' !() a
- wrapIdentity' :: a -> Identity' a
- unwrapIdentity' :: Identity' a -> a
- newtype Traversed (f :: Type -> Type) a = Traversed (f a)
- runTraversed :: Functor f => Traversed f a -> f ()
- data OrT (f :: Type -> Type) a = OrT !Bool (f a)
- wrapOrT :: f a -> OrT f a
- (#.) :: Coercible b c => (b -> c) -> (a -> b) -> a -> c
- (.#) :: Coercible a b => (b -> c) -> (a -> b) -> a -> c
- uncurry' :: (a -> b -> c) -> (a, b) -> c

# Documentation

data Identity' a Source #

Constructors

Identity' !() a |

#### Instances

Instances details

Applicative Identity' Source # |
Instance details Defined in Optics.Internal.Utils Methods pure :: a -> Identity' a Source # (<*>) :: Identity' (a -> b) -> Identity' a -> Identity' b Source # liftA2 :: (a -> b -> c) -> Identity' a -> Identity' b -> Identity' c Source # (*>) :: Identity' a -> Identity' b -> Identity' b Source # (<*) :: Identity' a -> Identity' b -> Identity' a Source #
Functor Identity' Source # |
Instance details Defined in Optics.Internal.Utils Methods fmap :: (a -> b) -> Identity' a -> Identity' b Source # (<$) :: a -> Identity' b -> Identity' a Source #
Mapping (IxStar Identity') Source # |
Instance details Defined in Optics.Internal.Utils Methods roam :: ((a -> b) -> s -> t) -> IxStar Identity' i a b -> IxStar Identity' i s t Source # iroam :: ((i -> a -> b) -> s -> t) -> IxStar Identity' j a b -> IxStar Identity' (i -> j) s t Source #
Mapping (Star Identity') Source # |
Instance details Defined in Optics.Internal.Utils Methods roam :: ((a -> b) -> s -> t) -> Star Identity' i a b -> Star Identity' i s t Source # iroam :: ((i -> a -> b) -> s -> t) -> Star Identity' j a b -> Star Identity' (i -> j) s t Source #

wrapIdentity' :: a -> Identity' a Source #

Mark a value for evaluation to whnf.

This allows us to, when applying a setter to a structure, evaluate only the parts that we modify. If an optic focuses on multiple targets, Applicative instance of Identity' makes sure that we force evaluation of all of them, but we leave anything else alone.

unwrapIdentity' :: Identity' a -> a Source #

newtype Traversed (f :: Type -> Type) a Source #

Helper for `traverseOf_` and the like for better efficiency than the foldr-based version.

Note that the argument `a` of the result should not be used.

Constructors

Traversed (f a) |

#### Instances

Instances details

Applicative f => Monoid (Traversed f a) Source # |
Instance details Defined in Optics.Internal.Utils Methods mempty :: Traversed f a Source # mappend :: Traversed f a -> Traversed f a -> Traversed f a Source # mconcat :: [Traversed f a] -> Traversed f a Source #
Applicative f => Semigroup (Traversed f a) Source # |
Instance details Defined in Optics.Internal.Utils Methods (<>) :: Traversed f a -> Traversed f a -> Traversed f a Source # sconcat :: NonEmpty (Traversed f a) -> Traversed f a Source # stimes :: Integral b => b -> Traversed f a -> Traversed f a Source #

runTraversed :: Functor f => Traversed f a -> f () Source #

data OrT (f :: Type -> Type) a Source #

Helper for `failing` family to visit the first fold only once.

Constructors

OrT !Bool (f a) |

#### Instances

Instances details

Applicative f => Applicative (OrT f) Source # |
Instance details Defined in Optics.Internal.Utils Methods pure :: a -> OrT f a Source # (<*>) :: OrT f (a -> b) -> OrT f a -> OrT f b Source # liftA2 :: (a -> b -> c) -> OrT f a -> OrT f b -> OrT f c Source # (*>) :: OrT f a -> OrT f b -> OrT f b Source # (<*) :: OrT f a -> OrT f b -> OrT f a Source #
Functor f => Functor (OrT f) Source # |
Instance details Defined in Optics.Internal.Utils Methods fmap :: (a -> b) -> OrT f a -> OrT f b Source # (<$) :: a -> OrT f b -> OrT f a Source #

wrapOrT :: f a -> OrT f a Source #

Wrap the applicative action in `OrT` so that we know later that it was executed.

(#.) :: Coercible b c => (b -> c) -> (a -> b) -> a -> c infixr 9 Source #

Composition operator where the first argument must be an identity function up to representational equivalence (e.g. a newtype wrapper or unwrapper), and will be ignored at runtime.

(.#) :: Coercible a b => (b -> c) -> (a -> b) -> a -> c infixl 8 Source #

Composition operator where the second argument must be an identity function up to representational equivalence (e.g. a newtype wrapper or unwrapper), and will be ignored at runtime.

uncurry' :: (a -> b -> c) -> (a, b) -> c Source #

`uncurry` with no lazy pattern matching for more efficient code.

Since: 0.3