[Haskell-cafe] Tail-call optimization

Joel Reymont joelr1 at gmail.com
Sun Dec 11 18:54:28 EST 2005


Thank you Andrew! Does it have any effect on performance? Is there a  
speed up of any sort from not passing parameters?

On Dec 11, 2005, at 11:50 PM, ajb at spamcop.net wrote:

> Good, but even better is this:
>
> writeLoop :: (Event a -> IO ()) -> Handle -> (SSL, BIO, BIO) -> IO ()
> writeLoop post h ssl
>   = loop
>   where
>     loop = do handle (\e -> post $ NetworkError e) $
>                 do cmd <- read h ssl
>                    post $! Cmd $! cmd
>               loop
>
> Avoiding parameter passing can make your code a lot easier to read.

--
http://wagerlabs.com/







More information about the Haskell-Cafe mailing list