module Control.Lens.Compat ( to , module Control.Lens ) where import Control.Lens hiding (to) import qualified Control.Lens as Lens -- | Build an (index-preserving) 'Getter' from an arbitrary Haskell function. -- See "Control.Lens".'Lens.to' for details. -- -- In , the constraint -- @'Functor' f@ is missing from the definition of 'Lens.to'. When compiling -- with GHC 8.0, this leads to warnings for definitions like -- -- @ -- foo :: Getter Bar Foo -- foo = to fooFromBar -- @ -- -- because of the redundant @'Functor' f@ constraint. This definition is -- identical to "Control.Lens".'Lens.to' except for the additional constraint -- @'Functor' f@. to :: (Profunctor p, Functor f, Contravariant f) => (s -> a) -> Optic' p f s a to k = getter where getter = Lens.to k _fakeFunctorConstraint = rmap (fmap undefined) . getter