Last active
March 1, 2019 19:53
-
-
Save benjamin-hodgson/5b36259986055d32adea56d0a7fa688f to your computer and use it in GitHub Desktop.
fmap f x <*> fmap g y = (\x y -> f x (g y)) <$> x <*> y
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
fmap f x <*> fmap g y | |
(pure f <*> x) <*> (pure g <*> y) -- definition of fmap | |
pure (.) <*> (pure f <*> x) <*> pure g <*> y -- composition | |
pure (.) <*> pure (.) <*> pure f <*> x <*> pure g <*> y -- composition | |
pure ((.) .) <*> pure f <*> x <*> pure g <*> y -- homomorphism | |
pure ((.) . f) <*> x <*> pure g <*> y -- homomorphism | |
pure ($ g) <*> (pure ((.) . f) <*> x) <*> y -- interchange | |
pure (.) <*> pure ($ g) <*> pure ((.) . f) <*> x <*> y -- composition | |
pure (($ g) .) <*> pure ((.) . f) <*> x <*> y -- homomorphism | |
pure (($ g) . ((.) . f)) <*> x <*> y -- homomorphism | |
pure ((. g) . f) <*> x <*> y -- i cheated and used pointfree.io | |
(\x y -> f x (g y)) <$> x <*> y -- definition of (.) and <$> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment