@@ -24,11 +24,11 @@ module Control.Optics.Linear.Internal
2424 , traversed
2525 -- * Using optics
2626 , get , set , gets
27- , match , match' , build
27+ , match , build
2828 , over , over'
2929 , traverseOf , traverseOf'
3030 , lengthOf
31- , withIso
31+ , withIso , withPrism
3232 -- * Constructing optics
3333 , iso , prism
3434 )
@@ -106,12 +106,8 @@ gets (Optical l) f s = getConst' (NonLinear.runKleisli (l (NonLinear.Kleisli (Co
106106set :: Optic_ (-> ) a b s t -> b -> s -> t
107107set (Optical l) x = l (const x)
108108
109- match :: Optic_ (Linear. Kleisli (Either a )) a b s t -> s ->. Either t a
110- match (Optical l) = withIso swap (\ x _ -> x) . Linear. runKleisli (l (Linear. Kleisli Left ))
111-
112- -- will be redundant with multiplicity polymorphism
113- match' :: Optic_ (NonLinear. Kleisli (Either a )) a b s t -> s -> Either t a
114- match' (Optical l) = withIso swap (\ x _ -> forget x) P. . NonLinear. runKleisli (l (NonLinear. Kleisli Left ))
109+ match :: Optic_ (Market a b ) a b s t -> s ->. Either t a
110+ match (Optical l) = snd (runMarket (l (Market id Right )))
115111
116112build :: Optic_ (Linear. CoKleisli (Const b )) a b s t -> b ->. t
117113build (Optical l) x = Linear. runCoKleisli (l (Linear. CoKleisli getConst')) (Const x)
@@ -139,3 +135,7 @@ iso f g = Optical (dimap f g)
139135withIso :: Optic_ (Exchange a b ) a b s t -> ((s ->. a ) -> (b ->. t ) -> r ) -> r
140136withIso (Optical l) f = f fro to
141137 where Exchange fro to = l (Exchange id id )
138+
139+ withPrism :: Optic_ (Market a b ) a b s t -> ((b ->. t ) -> (s ->. Either t a ) -> r ) -> r
140+ withPrism (Optical l) f = f b m
141+ where Market b m = l (Market id Right )
0 commit comments