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

Moduleoptics-core-0.4.1.1Haskell2010

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