@@ -21,6 +21,7 @@
2121-----------------------------------------------------------------------------
2222module Data.Generics.Internal.Profunctor.Prism where
2323
24+import Data.Bifunctor (bimap)
2425import Data.Profunctor (Choice(..), Profunctor(..))
2526import Data.Tagged
2627import Data.Profunctor.Unsafe ((#.), (.#))
@@ -44,12 +45,12 @@ prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b
4445prism bt seta eta = dimap seta (either id bt) (right' eta)
4546
4647_Left :: Prism (Either a c) (Either b c) a b
47−_Left = prism Left $ either Right (Left . Right)
48+_Left = left'
4849
4950_Right :: Prism (Either c a) (Either c b) a b
50−_Right = prism Right $ either (Left . Left) Right
51+_Right = right'
5152
52−prismPRavel :: (Market a b a b -> Market a b s t) -> Prism s t a b
53+prismPRavel :: APrism s t a b -> Prism s t a b
5354prismPRavel l pab = (prism2prismp $ l idPrism) pab
5455
5556build :: (Tagged b b -> Tagged t t) -> b -> t
@@ -65,9 +66,7 @@ without' :: Prism s t a b -> Prism s t c d -> Prism s t (Either a c) (Either b d
6566without' k =
6667 withPrism k $ \bt _ k' ->
6768 withPrism k' $ \dt setc ->
68− prism (foldEither bt dt) $ \s -> fmap Right (setc s)
69− where foldEither _ g (Right r) = g r
70− foldEither f _ (Left l) = f l
69+ prism (either bt dt) $ \s -> fmap Right (setc s)
7170{-# INLINE without' #-}
7271
7372withPrism :: APrism s t a b -> ((b -> t) -> (s -> Either t a) -> r) -> r
@@ -85,8 +84,7 @@ gsum f _ (L1 x) = f x
8584gsum _ g (R1 y) = g y
8685
8786plus :: (a -> b) -> (c -> d) -> Either a c -> Either b d
88−plus f _ (Left x) = Left (f x)
89−plus _ g (Right y) = Right (g y)
87+plus = bimap
9088
9189--------------------------------------------------------------------------------
9290-- Market