<div dir="ltr">Try using guards:<br>displayD :: IO () -> String -> Int<br>
displayD string count =<br>
        | count > 0 = hPutStr stdout string<br>
        | otherwise = displayD string (count - 1)<br><br>Alternatively use if, then, else.<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 9, 2014 at 2:03 AM, Alexej Magura <span dir="ltr"><<a href="mailto:sickhadas@gmail.com" target="_blank">sickhadas@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">K, so I have a function that I’m writing that takes a *string* and a *count* and prints the *string* to STDOUT *count* times:<br>

<br>
displayD :: IO () -> String -> Int<br>
displayD string count = do<br>
        (count > 0) && hPutStr stdout string<br>
        (count > 0) && displayD string (count - 1)<br>
<br>
However, when I try to compile the file, I get several errors; here’s a pastebin: <a href="http://pastebin.com/DEsuAvfz" target="_blank">http://pastebin.com/DEsuAvfz</a><br>
<br>
What I’m trying to do here is check to see if *count* is greater than 0, and then if it is, then I’d like to print *string* to STDOUT until *count* equals 0.  I tried doing it via pattern matching, like so:<br>
<br>
displayD string (count > 0) = do<br>
<br>
But I haven’t seen any examples of how to do pattern matching in functions using *do*, that is *IO*, so I’m unsure if the above is even anywhere near correct.<br>
<br>
Still very uncomfortable with declaring function types: I have a hard time figuring out which type is returned and what type is expected as an arg.  My initial guess is that the *first* type specified is the one returned, but I’m not sure.<br>

<span class="HOEnZb"><font color="#888888"><br>
-- <br>
Alexej Magura<br>
Sent with Airmail<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>
</font></span></blockquote></div><br></div>