<div dir="ltr"><br><br><div class="gmail_quote">On Sun, May 15, 2011 at 2:56 PM, aditya siram <span dir="ltr"><<a href="mailto:aditya.siram@gmail.com">aditya.siram@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
You can also try the applicative way:<br>(<$>) :: (a -> b) -> f a -> f b<br><br>import Control.Applicative<br>-- Think of the <$> as a monadic version of $<br>main = putStrLn <$> readFile "contents.txt"<br>
<br></blockquote><div>Actually, <$> is just a synonym for fmap, so this will have the same problems as the fmap approach.</div><div><br></div><div>Michael</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Or if you want to chain the functions and not worry about the "contents.txt" argument:<br><br>import Control.Monad<br>main= (readFile >=> putStrLn) "contents.txt"<br><br>-deech<br><br><div class="gmail_quote">
<div class="im">
On Sun, May 15, 2011 at 1:27 AM, Christopher Howard <span dir="ltr"><<a href="mailto:christopher.howard@frigidcode.com" target="_blank">christopher.howard@frigidcode.com</a>></span> wrote:<br></div><div><div></div>
<div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I understand that one can bind the unwrapped results of IO functions to<br>
variables, and pass them to functions, like so:<br>
<br>
main = do filecontents <- readFile "data.txt"<br>
putStrLn filecontents<br>
<br>
But does the syntax allow you to cut out the middle man, so to speak,<br>
and bind the results directly to the parameter? Like<br>
<br>
-- Tried this and it didn't work.<br>
main = do putStrLn (<- readFile "data.txt")<br>
<font color="#888888"><br>
--<br>
<a href="http://frigidcode.com" target="_blank">frigidcode.com</a><br>
<a href="http://theologia.indicium.us" target="_blank">theologia.indicium.us</a><br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</font></blockquote></div></div></div><br>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>