I always wandered, does ghc do tail-call optimization?

Would it optimize the two variants of the function below or just the first one?

--- Proper?

writeLoop :: (Event a -> IO ()) -> Handle -> (SSL, BIO, BIO) -> IO ()
writeLoop post h ssl =
    do handle (\e -> post $ NetworkError e) $
              do cmd <- read h ssl
                 post $! Cmd $! cmd
       writeLoop post h ssl

--- Bad?

writeLoop :: (Event a -> IO ()) -> Handle -> (SSL, BIO, BIO) -> IO ()
writeLoop post h ssl =
    do handle (\e -> post $ NetworkError e) $
              do cmd <- read h ssl
                 post $! Cmd $! cmd
                 writeLoop post h ssl

        Thanks, Joel

--
http://wagerlabs.com/





_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to