Created
September 25, 2012 18:42
-
-
Save reinh/3783635 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 | |
import Control.Monad.Instances | |
palindrome :: String -> Bool | |
palindrome = ap (==) reverse | |
palindrome "radar" --> True |
The function monad is funny. Maybe it's just that I don't work with it too much, but I always find it sort of unpredictable compared to the other monads. Contrast this to, say, the Arrow definition for functions which almost always seems to make code clearer.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ap
for the instance(-> r)
(the function monad) is:ap g f r = g r (f r)