[Haskell-beginners] IO loops with tail call

Yasuyuki Ogawa yuka_pon20 at yahoo.co.jp
Sat Nov 6 12:54:26 EDT 2010


Hello!

I wrote a simple echo program which end up with input "q":

echo = do
  str <- getLine
  if (str == "q")
    then return ()
    else putStrLn str >> echo

then I thought it is not tail call because if expressions
return a value. (is it right?) So I changed a code:

echo "q" = return ()
echo xs  = do
  putStrLn xs
  xs' <- getLine
  echo xs'

but Monad connections are too complicated so that
I'm not sure it is tail call. Am I wrong?

Thank you!
--------------------------------------
Get the new Internet Explorer 8 optimized for Yahoo! JAPAN
http://pr.mail.yahoo.co.jp/ie8/


More information about the Beginners mailing list