ekmett / profunctors

Haskell 98 Profunctors
http://hackage.haskell.org/package/profunctors
Other
70 stars 43 forks source link

Add the reach function to the Strong class #88

Open guaraqe opened 4 years ago

guaraqe commented 4 years ago

This adds the reach function to the Strong class. It has the following type:

reach :: (forall f. Functor f => (a -> f b) -> (s -> f t)) -> p a b -> p s t

It has two uses:

It is mutually defined in terms of second', and first' was modified to be defined in terms of reach, which means that no existing code should break.

I had to add a Functor dependency to the Kleisli instance for Strong to satify older versions of GHC. I don't know if this is the best solution.

guaraqe commented 4 years ago

I just checked and it seems that the same error due to Functor and Monad happens in the Traversing class, that was not touched in this PR. If compatibility with GHC 7.8 is not required, I can remove the workaround I mentioned above in the Kleisli instance.