Safe Haskell | None |
---|---|
Language | Haskell2010 |
Agda.Utils.Lens
Description
A cut-down implementation of lenses, with names 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 -> i) -> m ()
- (%==) :: MonadState o m => Lens' o i -> (i -> m i) -> m ()
- (.=) :: MonadState o m => Lens' o i -> i -> m ()
- (^.) :: o -> Lens' o i -> i
- contains :: Ord k => k -> Lens' (Set k) Bool
- focus :: forall (m :: Type -> Type) o i a. Monad m => Lens' o i -> StateT i m a -> StateT o m a
- iso :: (o -> i) -> (i -> o) -> Lens' o i
- key :: Ord k => k -> Lens' (Map k v) (Maybe v)
- lFst :: forall a b f. Functor f => (a -> f a) -> (a, b) -> f (a, b)
- lSnd :: forall a b f. Functor f => (b -> f b) -> (a, b) -> f (a, b)
- lens :: LensGet o i -> LensSet o i -> Lens' o i
- lensProduct :: Lens' s a -> Lens' s b -> Lens' s (a, b)
- locally :: MonadReader o m => Lens' o i -> (i -> i) -> m a -> m a
- locally' :: ((o -> o) -> m a -> m a) -> Lens' o i -> (i -> i) -> m a -> m a
- locallyState :: MonadState o m => Lens' o i -> (i -> i) -> m r -> m r
- over :: Lens' o i -> LensMap o i
- set :: Lens' o i -> LensSet o i
- use :: MonadState o m => Lens' o i -> m i
- view :: MonadReader o m => Lens' o i -> m i
- type Lens' o i = forall (f :: Type -> Type). Functor f => (i -> f i) -> o -> f o
- 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')
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 -> i) -> m () infix 4 Source #
Modify a part of the state.
(%==) :: MonadState o m => Lens' o i -> (i -> m i) -> m () infix 4 Source #
Modify a part of the state monadically.
(.=) :: MonadState o m => Lens' o i -> i -> m () infix 4 Source #
Write a part of the state.
(^.) :: o -> Lens' o i -> i infixl 8 Source #
Get inner part i
of structure o
as designated by Lens' o i
.
focus :: forall (m :: Type -> Type) o i a. Monad m => Lens' o i -> StateT i m a -> StateT o m a Source #
Focus on a part of the state for a stateful computation.
lensProduct :: Lens' s a -> Lens' s b -> Lens' s (a, b) Source #
Only sound if the lenses are disjoint!
locally :: MonadReader o m => Lens' o i -> (i -> i) -> m a -> m a 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 :: Lens' o i -> LensMap o i Source #
Modify inner part i
of structure o
using a function i -> i
.
use :: MonadState o m => Lens' o i -> m i Source #
Read a part of the state.
view :: MonadReader o m => Lens' o i -> m i Source #
Ask for part of read-only state.
type Lens' o i = forall (f :: Type -> Type). Functor f => (i -> f i) -> o -> f o Source #
Van Laarhoven style homogeneous lenses. Mnemoic: "Lens outer inner", same type argument order as 'get :: o -> i'.