Safe Haskell | None |
---|---|
Language | Haskell2010 |
Minimal redefine + re-export of a lens package, fclabels
- type (:->) a b = Lens' a b
- type Lens a b = Lens' a b
- (^*) :: (a :-> b) -> (b :-> c) -> a :-> c
- (^.) :: s -> Getting a s a -> a
- getL :: (f :-> a) -> f -> a
- (^=) :: (a :-> b) -> b -> a -> a
- (^$=) :: (a :-> b) -> (b -> b) -> a -> a
- (=:) :: MonadState f m => (f :-> o) -> o -> m ()
- (=$:) :: MonadState f m => (f :-> o) -> (o -> o) -> m ()
- modifyAndGet :: MonadState f m => (f :-> o) -> (o -> (a, o)) -> m a
- (=$^:) :: MonadState f m => (f :-> o) -> (o -> (a, o)) -> m a
- modL :: MonadState f m => (f :-> o) -> (o -> (a, o)) -> m a
- getl :: MonadState f m => (f :-> o) -> m o
- mkLabel :: Name -> Q [Dec]
- fstl :: Lens (a, b) a
- sndl :: Lens (a, b) b
- fst3l :: Lens (a, b, c) a
- snd3l :: Lens (a, b, c) b
- trd3l :: Lens (a, b, c) c
- isoMb :: String -> (f :-> Maybe o) -> f :-> o
- isoMbWithDefault :: o -> (f :-> Maybe o) -> f :-> o
Documentation
Access
(^.) :: s -> Getting a s a -> a infixl 8 #
(^.
) applies a getter to a value; in other words, it gets a value out of a structure using a getter (which can be a lens, traversal, fold, etc.).
Getting 1st field of a tuple:
(^.
_1
) :: (a, b) -> a (^.
_1
) =fst
When (^.
) is used with a traversal, it combines all results using the Monoid
instance for the resulting type. For instance, for lists it would be simple concatenation:
>>>
("str","ing") ^. each
"string"
The reason for this is that traversals use Applicative
, and the Applicative
instance for Const
uses monoid concatenation to combine “effects” of Const
.
A non-operator version of (^.
) is called view
, and it's a bit more general than (^.
) (it works in MonadReader
). If you need the general version, you can get it from microlens-mtl; otherwise there's view
available in Lens.Micro.Extras.
getL :: (f :-> a) -> f -> a Source #
Alias for get
to avoid conflict with state get; not happy choice because of getl
(^=) :: (a :-> b) -> b -> a -> a infixr 4 Source #
functional setter, which acts like a field assigner
(=:) :: MonadState f m => (f :-> o) -> o -> m () infixr 4 Source #
monadic set
(=$:) :: MonadState f m => (f :-> o) -> (o -> o) -> m () infixr 4 Source #
monadic modify & set
modifyAndGet :: MonadState f m => (f :-> o) -> (o -> (a, o)) -> m a Source #
monadic modify & set & get
(=$^:) :: MonadState f m => (f :-> o) -> (o -> (a, o)) -> m a infixr 4 Source #
monadic modify & set & get
modL :: MonadState f m => (f :-> o) -> (o -> (a, o)) -> m a Source #
monadic modify & set & get
getl :: MonadState f m => (f :-> o) -> m o Source #
monadic get