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

Modulemicrolens-0.4.14.0Haskell2010

Lens.Micro.Extras

  • 2 values
valueview :: Getting a s a -> s -> a
#

view is a synonym for (^.):

Example1 expression
view _1 (1, 2)1

The reason it's not in Lens.Micro is that view in lens has a more general signature:

view :: MonadReader s m => Getting a s a -> m a

So, you would be able to use this view with functions, but not in various reader monads. For most people this shouldn't be an issue; if it is for you, use view from microlens-mtl.

valuepreview :: Getting (First a) s a -> s -> Maybe a
#

preview is a synonym for (^?):

Example1 expression
preview _head [1,2,3]Just 1

The reason it's not in Lens.Micro is that preview in lens has a more general signature:

preview :: MonadReader s m => Getting (First a) s a -> m (Maybe a)

Just like with view, you would be able to use this preview with functions, but not in reader monads; if this is an issue for you, use preview from microlens-mtl.