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-lens-2.2.2.0Haskell2010

Data.Generics.Sum.Typed

Derive constructor-field-type-based prisms generically.

  • 1 class

Prisms

1 declaration
classclass AsType a s where
#

Sums that have a constructor with a field of the given type.

Methods

  • _Typed :: Prism' s a

    A prism that projects a constructor uniquely identifiable by the type of its field. Compatible with the lens package's Control.Lens.Prism type.

    Example3 expressions
    dog ^? _Typed @DogJust (MkDog {name = "Shep", age = Age 3})cat ^? _Typed @(Name, Age)Just ("Mog",Age 5)dog ^? _Typed @Age......... The type Animal contains multiple constructors whose fields are of type Age.... The choice of constructor is thus ambiguous, could be any of:... Duck... Turtle...
  • injectTyped :: a -> s

    Inject by type.

  • projectTyped :: s -> Maybe a

    Project by type.

Instances3AsType
  • AsType Void aDefined in generic-lens-2.2.2.0 · Data.Generics.Sum.Typed

    Uncluttering type signatures (see Void)

    Example1 expression
    :t +d _Typed @Int_Typed @Int  :: (AsType Int s, Choice p, Applicative f) =>     p Int (f Int) -> p s (f s)
  • AsType a VoidDefined in generic-lens-2.2.2.0 · Data.Generics.Sum.Typed

    Uncluttering type signatures (see Void)

    Example1 expression
    :t +d _Typed_Typed  :: (AsType a s, Choice p, Applicative f) => p a (f a) -> p s (f s)
  • Context a s => AsType a sDefined in generic-lens-2.2.2.0 · Data.Generics.Sum.Typed