Created
January 1, 2015 00:53
-
-
Save tel/3e79b69da08828236e98 to your computer and use it in GitHub Desktop.
CPS causes function composition to flip directions
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
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE TypeOperators #-} | |
type b <~ a = forall c . (b -> c) -> a -> c | |
back :: (a -> b) -> (b <~ a) | |
back f = (. f) | |
fwd :: (b <~ a) -> (a -> b) | |
fwd g = g id | |
(>>>) :: (a -> b) -> (b -> c) -> (a -> c) | |
f >>> g = fwd (back f . back g) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment