HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduleeither-n-0.1.0.0Haskell2010

Data.Lens.Injection.Injection4

The fourth injection of a sum type, as a prism. The sum-type dual of Control.Lens.Field4.

Synopsis
  • Packageeither-n-0.1.0.0
  • Exports1
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceInjection4.hs
classclass Injection4 s t a b | s -> a, t -> b, s b -> t, t a -> s where

Access the fourth constructor of a sum type.

Where Control.Lens._4 is the fourth projection out of a product, _I4 is the fourth injection into a sum.

The default implementation is the prism to the fourth constructor of a Generic type, injection (Proxy :: Proxy 3).

Example3 expressions
data T = C1 | C2 | C3 | C4 Int | C5 deriving (Show, Generic)instance Injection4 T T Int IntC4 1 ^? _I4Just 1
Example1 expression
C5 ^? _I4Nothing
Example1 expression
_I4 # 1 :: TC4 1

Methods