Skip to content

Instantly share code, notes, and snippets.

@awagner83
Created January 2, 2012 20:25
Show Gist options
  • Save awagner83/1551970 to your computer and use it in GitHub Desktop.
Save awagner83/1551970 to your computer and use it in GitHub Desktop.
Simple haskell var passing example.
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