Created
December 28, 2010 12:56
-
-
Save debasishg/757184 to your computer and use it in GitHub Desktop.
Sample use of a monad
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
-- example of a monadic operation | |
do s <- readFile f | |
writeFile g s | |
return s | |
-- gets translated to | |
readFile f >>= \s-> | |
writeFile g s >>= \_-> | |
return s | |
-- >>= does the sequencing and is called the "bind" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment