Skip to content

Instantly share code, notes, and snippets.

@benjamin-hodgson
Last active March 1, 2019 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjamin-hodgson/5b36259986055d32adea56d0a7fa688f to your computer and use it in GitHub Desktop.
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
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