type Lens a b = forall f. Functor f => (b -> f b) -> a -> f a 2 _1 :: Lens (a, b) a 3 _1 f (x1, y) = fmap (\x2 -> (x2, y)) (f x1) 4 5 get :: Lens a b -> a -> b 6 get l x = getConst (l Const x) 1 get _1 (42, 'a') 2 = getConst (_1 Const (42, 'a')) -- Def. of 'get' 3 = getConst (fmap (\x2 -> (x2, 'a')) (Const 42)) -- Def. of '_1' 4 = getConst (Const 42) -- Def. of 'fmap' for 'Const 5 = 42 -- The Answer! Markus Hauck (@markus1189) The Power Of Const 9