A prism to the nth constructor (counting from 0) of a type with a Generic instance,
where n is given by a proxy, such as Proxy @0.
The focus of the prism depends on the fields of the constructor:
No fields: the focus is
().One field: the focus is that field.
More than one field: the focus is any type with a single constructor that has the same fields, such as a tuple.
T1 'x' ^? injection (Proxy @0)Just 'x'
T2 ^? injection (Proxy @0)Nothing
Unlike the InjectionN classes, injection has no functional dependencies,
so a type-changing use may need a type annotation.
over (injection (Proxy @0)) show (T1 1) :: T StringT1 "1"
(T2 :: T Char) ^? injection (Proxy @1)Just ()
(T3 1 True :: T Char) ^? injection (Proxy @2) :: Maybe (Int, Bool)Just (1,True)
injection (Proxy @2) # (1, True) :: T CharT3 1 True