Created
January 24, 2015 00:09
-
-
Save ttuegel/9a3be681985fc5837a38 to your computer and use it in GitHub Desktop.
Function application versus evaluation
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
ghci> import Control.Monad (liftM) | |
ghci> :t liftM | |
liftM :: Monad m => (a1 -> r) -> m a1 -> m r | |
ghci> import Debug.Trace (trace) | |
ghci> liftM (\x -> trace "function applied" (x + 3)) [1 :: Int, 2, 3] | |
[function applied | |
4,function applied | |
5,function applied | |
6] | |
ghci> liftM (trace "function evaluated" (+ 3)) [1 :: Int, 2, 3] | |
[function evaluated | |
4,5,6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment