HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleAgda-2.7.0.1Haskell2010

Agda.Utils.Lens

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

  • 4 types
  • 19 values
  • PackageAgda-2.7.0.1
  • Exports23
  • LanguageHaskell2010
  • LicenceMIT
  • SourceLens.hs
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'.

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

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

valueover :: Lens' o i -> LensMap o i
#

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

typetype LensSet o i = i -> o -> o
#
typetype LensMap o i = (i -> i) -> o -> o
#
valuelFst :: Functor f => (a -> f a) -> (a, b) -> f (a, b)
#
valuelSnd :: Functor f => (b -> f b) -> (a, b) -> f (a, b)
#
valueiso :: (o -> i) -> (i -> o) -> Lens' o i
#

Build a lens out of an isomorphism.

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(%%=) :: MonadState o m => Lens' o i -> (i -> m (i, r)) -> m r
#

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

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
#
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