You can also try the applicative way:
(<$>) :: (a -> b) -> f a -> f b
import Control.Applicative
-- Think of the <$> as a monadic version of $
main = putStrLn <$> readFile "contents.txt"
Or if you want to chain the functions and not worry about the "contents.txt" argument:
import Control.Monad
main= (readFile >=> putStrLn) "contents.txt"
-deech
I understand that one can bind the unwrapped results of IO functions to
variables, and pass them to functions, like so:
main = do filecontents <- readFile "data.txt"
putStrLn filecontents
But does the syntax allow you to cut out the middle man, so to speak,
and bind the results directly to the parameter? Like
-- Tried this and it didn't work.
main = do putStrLn (<- readFile "data.txt")
--
frigidcode.com
theologia.indicium.us
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners