Convert from the data type to its representation (or back)
view (generic % re generic) "hello" :: String"hello"
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Moduleoptics-core-0.4.1.1Haskell2010
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.
Convert from the data type to its representation (or back)
view (generic % re generic) "hello" :: String"hello"
Convert from the data type to its representation (or back)