Access the second constructor of a sum type.
Where Control.Lens._2 is the second projection out of a product, _I2 is the second
injection into a sum.
The default implementation is the prism to the second constructor of a
Generic type, injection (Proxy :: Proxy 1).
data T = C1 | C2 Int | C3 deriving (Show, Generic)instance Injection2 T T Int IntC2 1 ^? _I2Just 1
C3 ^? _I2Nothing
_I2 # 1 :: TC2 1
Instances9Injection2, …
Injection2 Bool Bool () ()Defined in either-n-0.1.0.0 · Data.Lens.Injection.Injection2Example1 expression True ^? _I2Just ()
Example1 expression False ^? _I2Nothing
Example1 expression _I2 # () :: BoolTrue
Injection2 Ordering Ordering () ()Defined in either-n-0.1.0.0 · Data.Lens.Injection.Injection2Example1 expression EQ ^? _I2Just ()
Example1 expression LT ^? _I2Nothing
Example1 expression GT ^? _I2Nothing
Example1 expression _I2 # () :: OrderingEQ
Injection2 (Maybe a) (Maybe b) a bDefined in either-n-0.1.0.0 · Data.Lens.Injection.Injection2Example1 expression Just 1 ^? _I2Just 1
Example1 expression (Nothing :: Maybe Int) ^? _I2Nothing
Example1 expression _I2 # 1 :: Maybe IntJust 1
Example1 expression over _I2 show (Just 1)Just "1"
Injection2 [a] [b] (NonEmpty a) (NonEmpty b)Defined in either-n-0.1.0.0 · Data.Lens.Injection.Injection2A list is the sum of the empty list and a non-empty list.
Example1 expression [1, 2, 3] ^? _I2Just (1 :| [2,3])
Example1 expression ([] :: [Int]) ^? _I2Nothing
Example1 expression _I2 # (1 :| [2, 3]) :: [Int][1,2,3]
Example1 expression over _I2 (fmap show) [1, 2, 3]["1","2","3"]
Injection2 (Either c a) (Either c b) a bDefined in either-n-0.1.0.0 · Data.Lens.Injection.Injection2Example1 expression (Right "x" :: Either Int String) ^? _I2Just "x"
Example1 expression (Left 1 :: Either Int String) ^? _I2Nothing
Example1 expression _I2 # "x" :: Either Int StringRight "x"
Example1 expression over _I2 show (Right True :: Either Int Bool)Right "True"
Injection2 (Either3 a b c) (Either3 a b' c) b b'Defined in either-n-0.1.0.0 · Data.Either3.Either3Example1 expression (Second3 True :: Either3 Int Bool String) ^? _I2Just True
Example1 expression _I2 # True :: Either3 Int Bool StringSecond3 True
Injection2 (Either3T Identity a b c) (Either3T Identity a b' c) b b'Defined in either-n-0.1.0.0 · Data.Either3.Either3TExample1 expression e3 (Second3 True) ^? _I2Just True
Injection2 (Sum f g a) (Sum f g' a) (g a) (g' a)Defined in either-n-0.1.0.0 · Data.Lens.Injection.Injection2Example1 expression (InR [1] :: Sum Maybe [] Int) ^? _I2Just [1]
Example1 expression (InL (Just 1) :: Sum Maybe [] Int) ^? _I2Nothing
Example1 expression _I2 # [1] :: Sum Maybe [] IntInR [1]
Injection2 ((:+:) f g p) ((:+:) f g' p) (g p) (g' p)Defined in either-n-0.1.0.0 · Data.Lens.Injection.Injection2Example1 expression (R1 [1] :: (Maybe :+: []) Int) ^? _I2Just [1]
Example1 expression (L1 (Just 1) :: (Maybe :+: []) Int) ^? _I2Nothing
Example1 expression _I2 # [1] :: (Maybe :+: []) IntR1 [1]