Created
September 21, 2013 18:30
-
-
Save qoelet/6652967 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- I finally got sick of reading books on Maybe and IO monads! | |
-- I spyed beyond that there must be mooarrr! | |
import Control.Monad.Identity | |
agent :: (Num a) => a -> Identity a | |
agent n = do | |
return n >>= (\n -> Identity (n * 2)) | |
main :: IO () | |
main = do | |
let x = 7 | |
putStrLn ("My double identity is " ++ show(runIdentity (agent x)) ++ "!") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment