As explained at the top of Control.Lens.Getter , a Getter ab is isomorphic (a -> b) . This means that they contain the same information and can be changed as desired. We can turn them into each other using the functions provided by the lens library:
fromGetter :: Getter ab -> (a -> b) fromGetter g = view g toGetter :: (a -> b) -> Getter ab toGetter = to
With this knowledge, you can use the Applicative instance for (->) , as shown by J. Abrahamson, to create the desired function:
myCombinator :: (b -> c -> d) -> Getter ab -> Getter ac -> Getter ad myCombinator fn g1 g2 = toGetter (fn <$> fromGetter g1 <*> fromGetter g2)
Reite
source share