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

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

Moduleoptics-core-0.4.2Haskell2010

GHC.Generics.Optics

Note: GHC.Generics exports a number of names that collide with Optics (at least to).

You can use hiding of imports to mitigate this to an extent. The following imports represent a fair compromise for user code:

import Optics
import GHC.Generics hiding (to)
import GHC.Generics.Optics

You can use generic to replace from and to from GHC.Generics.

  • 10 values
  • Packageoptics-core-0.4.2
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceOptics.hs
valuegeneric :: (Generic a, Generic b) => Iso a b (Rep a x) (Rep b y)
#

Convert from the data type to its representation (or back)

Example1 expression
view (generic % re generic) "hello" :: String"hello"
value_M1 :: Iso (M1 i c f p) (M1 j d g q) (f p) (g q)
#