HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

ModuleAgda-2.8.0.2Haskell2010

Agda.Utils.Lens

A cut-down implementation of lenses, with names taken from Edward Kmett's lens package.

  • 4 types
  • 21 values
  • PackageAgda-2.8.0.2
  • Exports26
  • LanguageHaskell2010
  • LicenceMIT
  • SourceLens.hs
value(%%=) :: MonadState o m => Lens' o i -> (i -> m (i, r)) -> m r
#

Modify a part of the state monadically, and return some result.

value(%=) :: MonadState o m => Lens' o i -> (i -> i) -> m ()
#

Modify a part of the state.

value(%==) :: MonadState o m => Lens' o i -> (i -> m i) -> m ()
#

Modify a part of the state monadically.

value(^.) :: o -> Lens' o i -> i
#

Get inner part i of structure o as designated by Lens' o i.

valueiso :: (o -> i) -> (i -> o) -> Lens' o i
#

Build a lens out of an isomorphism.

valuelFst :: Functor f => (a -> f a) -> (a, b) -> f (a, b)
#
valuelSnd :: Functor f => (b -> f b) -> (a, b) -> f (a, b)
#
valuelocally :: MonadReader o m => Lens' o i -> (i -> i) -> m a -> m a
#

Modify a part of the state in a subcomputation.

valuelocally' :: ((o -> o) -> m a -> m a) -> Lens' o i -> (i -> i) -> m a -> m a
#
valueover :: Lens' o i -> LensMap o i
#

Modify inner part i of structure o using a function i -> i.

valueset :: Lens' o i -> LensSet o i
#

Set inner part i of structure o as designated by Lens' o i.

typetype Lens' o i = forall (f :: Type -> Type). Functor f => (i -> f i) -> o -> f o
#

Van Laarhoven style homogeneous lenses. Mnemoic: "Lens outer inner", same type argument order as 'get :: o -> i'.

typetype LensMap o i = (i -> i) -> o -> o
#
typetype LensSet o i = i -> o -> o
#
value(<&>) :: Functor f => f a -> (a -> b) -> f b
#

Flipped version of <$>.

(<&>) = flip fmap
Examples

Apply (+1) to a list, a Just and a Right:

Example1 expression
Just 2 <&> (+1)Just 3
Example1 expression
[1,2,3] <&> (+1)[2,3,4]
Example1 expression
Right 3 <&> (+1)Right 4
method(&&&) :: a b c -> a b c' -> a b (c, c')
#

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'