on master help sign in
Do some eta expansion
1e77599Matthew Pickering
test/Spec.hs+2−2
@@ -47,7 +47,7 @@ type PrismP s t a b =
47type Traversal' s a = forall f. Applicative f => (a -> f a) -> s -> f s
47type Traversal' s a = forall f. Applicative f => (a -> f a) -> s -> f s
48
48
49prism :: (b -> t) -> (s -> Either t a) -> PrismP s t a b
49prism :: (b -> t) -> (s -> Either t a) -> PrismP s t a b
50−prism bt seta = dimap seta (either id bt) . right'
50+prism bt seta eta = dimap seta (either id bt) (right' eta)
51{-# INLINE prism #-}
51{-# INLINE prism #-}
52
52
53data Record4 a = MkRecord4
53data Record4 a = MkRecord4
@@ -97,7 +97,7 @@ subtypeLensManual f record
97data Sum1 = A Char | B Int | C () | D () deriving (Generic, Show)
97data Sum1 = A Char | B Int | C () | D () deriving (Generic, Show)
98
98
99sum1PrismManual :: PrismP Sum1 Sum1 Int Int
99sum1PrismManual :: PrismP Sum1 Sum1 Int Int
100−sum1PrismManual = prism g f
100+sum1PrismManual eta = prism g f eta
101 where
101 where
102 f s1 = case s1 of
102 f s1 = case s1 of
103 B i -> Right i
103 B i -> Right i