import Control.Lens prismToGetterF :: forall s t a b. Prism s t a b -> b -> t prismToGetterF p b = view foo b where foo :: Getter b t foo = re p -- From the lens haddocks: -- -- re :: AReview t b -> Getter b t -- -- Turn a Prism or Iso around to build a Getter. -- -- If you have an Iso, from is a more powerful version of this function that will return an Iso instead of a mere Getter. -- -- >>> 5 ^.re _Left -- Left 5 -- -- >>> 6 ^.re (_Left.unto succ) -- Left 7 -- -- review ≡ view . re -- reviews ≡ views . re -- reuse ≡ use . re -- reuses ≡ uses . re -- -- re :: Prism s t a b -> Getter b t -- re :: Iso s t a b -> Getter b t