Created
September 27, 2017 11:57
-
-
Save dcastro/9a2d2596d484865e0f1fec335e2a88fe to your computer and use it in GitHub Desktop.
Expanding `>>=` on functions
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
-- start with | |
(+) >>= id $ 2 | |
-- Expand `>>=` using the Monad instance for functions | |
-- instance Monad ((->) r) where | |
-- f >>= k = \ r -> k (f r) r | |
(\r -> id ((+) r) r) $ 2 | |
-- beta reduction | |
id ((+) 2) 2 | |
-- expand `id` | |
((+) 2) 2 | |
2 + 2 | |
4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment