| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Agda.Utils.Lens
Description
A cut-down implementation of lenses, with names mostly taken from Edward Kmett's lens package.
Synopsis
- (%%=) :: MonadState o m => Lens' o i -> (i -> m (i, r)) -> m r
- (%%=!) :: MonadState o m => Lens' o i -> (i -> m (i, r)) -> m r
- (%=) :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
- (%=!) :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
- (%==) :: MonadState s m => Lens' s a -> (a -> m a) -> m ()
- (%==!) :: MonadState s m => Lens' s a -> (a -> m a) -> m ()
- (%~) :: ASetter s t a b -> (a -> b) -> s -> t
- (%~!) :: ASetter s t a b -> (a -> b) -> s -> t
- (.=) :: MonadState s m => ASetter s s a b -> b -> m ()
- (.=!) :: MonadState s m => ASetter s s a b -> b -> m ()
- (.~) :: ASetter s t a b -> b -> s -> t
- (^.) :: s -> Getting a s a -> a
- contains :: Ord k => k -> Lens' (Set k) Bool
- iso :: (o -> i) -> (i -> o) -> Lens' o i
- key :: Ord k => k -> Lens' (Map k v) (Maybe v)
- lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
- lensProduct :: Lens' s a -> Lens' s b -> Lens' s (a, b)
- locally :: MonadReader r m => ASetter r r a b -> (a -> b) -> m c -> m c
- locallyState :: MonadState o m => Lens' o i -> (i -> i) -> m r -> m r
- over :: ASetter s t a b -> (a -> b) -> s -> t
- over' :: ASetter s t a b -> (a -> b) -> s -> t
- set :: ASetter s t a b -> b -> s -> t
- set' :: ASetter s t a b -> b -> s -> t
- use :: MonadState s m => Getting a s a -> m a
- view :: MonadReader s m => Getting a s a -> m a
- type ASetter s t a b = (a -> Identity b) -> s -> Identity t
- class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field3 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field4 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field5 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- type Getting r s a = (a -> Const r a) -> s -> Const r s
- type Lens s t a b = forall (f :: Type -> Type). Functor f => (a -> f b) -> s -> f t
- type Lens' s a = Lens s s a a
- type LensGet o i = o -> i
- type LensMap o i = (i -> i) -> o -> o
- type LensSet o i = i -> o -> o
- (<&>) :: Functor f => f a -> (a -> b) -> f b
- (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')
- (&) :: a -> (a -> b) -> b
Documentation
(%%=) :: MonadState o m => Lens' o i -> (i -> m (i, r)) -> m r infix 4 Source #
Modify a part of the state monadically, and return some result.
(%%=!) :: MonadState o m => Lens' o i -> (i -> m (i, r)) -> m r infix 4 Source #
Strictly modify a part of the state monadically, and return some result.
(%=) :: MonadState s m => ASetter s s a b -> (a -> b) -> m () infix 4 Source #
Modify a part of the state.
(%=!) :: MonadState s m => ASetter s s a b -> (a -> b) -> m () infix 4 Source #
Strictly modify a part of the state.
(%==) :: MonadState s m => Lens' s a -> (a -> m a) -> m () infix 4 Source #
Modify a part of the state monadically.
(%==!) :: MonadState s m => Lens' s a -> (a -> m a) -> m () infix 4 Source #
Strictly modify a part of the state monadically.
(.=) :: MonadState s m => ASetter s s a b -> b -> m () infix 4 Source #
Write a part of the state.
(.=!) :: MonadState s m => ASetter s s a b -> b -> m () infix 4 Source #
Strictly write a part of the state.
(^.) :: s -> Getting a s a -> a infixl 8 Source #
Get inner part i of structure o as designated by Lens' o i.
lensProduct :: Lens' s a -> Lens' s b -> Lens' s (a, b) Source #
Only sound if the lenses are disjoint!
locally :: MonadReader r m => ASetter r r a b -> (a -> b) -> m c -> m c Source #
Modify a part of the state in a subcomputation.
locallyState :: MonadState o m => Lens' o i -> (i -> i) -> m r -> m r Source #
Modify a part of the state locally.
over :: ASetter s t a b -> (a -> b) -> s -> t Source #
Modify inner part i of structure o using a function i -> i.
over' :: ASetter s t a b -> (a -> b) -> s -> t Source #
Strictly modify inner part i of structure o using a function i -> i.
set :: ASetter s t a b -> b -> s -> t Source #
Set inner part i of structure o as designated by Lens' o i.
set' :: ASetter s t a b -> b -> s -> t Source #
Strictly set inner part i of structure o as designated by Lens' o i.
use :: MonadState s m => Getting a s a -> m a Source #
Read a part of the state.
view :: MonadReader s m => Getting a s a -> m a Source #
Read part of the environment.
class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
class Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
class Field3 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
class Field4 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
type Lens s t a b = forall (f :: Type -> Type). Functor f => (a -> f b) -> s -> f t Source #
Van Laarhoven style homogeneous lenses. Mnemoic: "Lens outer inner", same type argument order as 'get :: o -> i'.
(&&&) :: Arrow a => a b c -> a b c' -> a b (c, c') infixr 3 #
Fanout: send the input to both argument arrows and combine their output.
The default definition may be overridden with a more efficient version if desired.
╭───────╮ c
b │ ┌─ f ─┼───>
>───┼─┤ │
│ └─ g ─┼───>
╰───────╯ c'(&) :: a -> (a -> b) -> b infixl 1 #
& is a reverse application operator. This provides notational
convenience. Its precedence is one higher than that of the forward
application operator $, which allows & to be nested in $.
This is a version of , where flip idid is specialized from a -> a to (a -> b) -> (a -> b)
which by the associativity of (->) is (a -> b) -> a -> b.
flipping this yields a -> (a -> b) -> b which is the type signature of &
Examples
>>>5 & (+1) & show"6"
>>>sqrt $ [1 / n^2 | n <- [1..1000]] & sum & (*6)3.1406380562059946
Since: base-4.8.0.0