Created
April 29, 2017 18:42
-
-
Save akhileshs/58c4becfa4dd7243ed4b62264cfe125e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
class Profunctor p where | |
dimap :: (a -> b) -> (c -> d) -> p b c -> p a d | |
-- lmap :: (a -> b) -> p b c -> p a c | |
-- rmap :: (c -> d) -> p b c -> p b d | |
instance Profunctor (->) where | |
-- dimap :: (a -> b) -> (c -> d) -> (->) b c -> (->) a d | |
dimap ab cd bc = cd . bc . ab | |
newtype Kleisli m b c = Kleisli { runKleisli :: b -> m c } | |
instance Monad m => Profunctor (Kleisli m) where | |
-- dimap :: (a -> b) -> (c -> d) -> Kleisli m b c -> Kleisli m a d | |
dimap ab cd (Kleisli bmc) = | |
Kleisli (liftM cd . bmc . ab) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment