Created
January 2, 2012 20:25
-
-
Save awagner83/1551970 to your computer and use it in GitHub Desktop.
Simple haskell var passing example.
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
import System.IO | |
main :: IO () | |
main = do | |
val <- getLine -- "val" here belongs to main's scope. | |
putStrLn (myfun val) -- pass the val to myfun, since it's out | |
-- of it's scope. | |
myfun :: String -> String | |
myfun a = "My value is " ++ a -- myfun knows nothing of 'val', as it | |
-- belongs to main's function scope |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment