I am stumped trying to print values returned from IO functions. How to print values returned from getEnv and getEnvironment? Thanks, Dave Feustel
Hello Dave, Sunday, March 11, 2007, 11:23:51 PM, you wrote:
I am stumped trying to print values returned from IO functions. How to print values returned from getEnv and getEnvironment?
don't try to print them. just realize that they are not exist :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
Dave:
I am stumped trying to print values returned from IO functions. How to print values returned from getEnv and getEnvironment?
import System.Environment main = do args <- getArgs env <- getEnvironment print args print env You evaluate the IO action, extracting its result. $ ./a.out hello ["hello"] [("PATH","/home/dons/bin:/home/dons/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/home/dons/bin:/sbin:/usr/sbin:/usr/local/sbin").... Note that the do notation is just syntactic sugar for the >>= function, getArgs >>= \ args -> getEnvironment >>= \ env -> print args >> print env It's probably a good idea to read up on monadic IO at some point. The best references are: http://darcs.haskell.org/yaht/yaht.pdf http://en.wikibooks.org/wiki/Haskell Also, a lot of articles here: http://haskell.org/haskellwiki/Blog_articles -- Don P.S. Best asked on the irc channel, you'll get a faster response :-)
participants (3)
-
unknown@example.com -
Bulat Ziganshin -
dons@cse.unsw.edu.au