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

Modulegeneric-optics-2.2.1.0Haskell2010

Data.Generics.Product.Any

Derive a variety of lenses generically.

  • 1 class

Lenses

1 declaration

Running example:

Example6 expressions
:set -XTypeApplications:set -XDataKinds:set -XDeriveGenericimport GHC.Genericsimport Optics.Core:{data Human = Human  { name    :: String  , age     :: Int  , address :: String  }  deriving (Generic, Show)human :: Humanhuman = Human "Tunyasz" 50 "London":}
classclass HasAny (sel :: k) s t a b | s sel -> a where
#

Methods

  • the :: Lens s t a b

    A lens that focuses on a part of a product as identified by some selector. Currently supported selectors are field names, positions and unique types.

    Example1 expression
    human ^. the @Int50
    Example1 expression
    human ^. the @"name""Tunyasz"
    Example1 expression
    human ^. the @3"London"
Instances3HasAny
  • HasField field s t a b => HasAny field s t a bDefined in generic-optics-2.2.1.0 · Data.Generics.Product.Any
  • HasPosition i s t a b => HasAny i s t a bDefined in generic-optics-2.2.1.0 · Data.Generics.Product.Any
  • (HasType a s, t ~ s, a ~ b) => HasAny a s t a bDefined in generic-optics-2.2.1.0 · Data.Generics.Product.Any