Derek Elkins wrote:
Both are poorish style.
reader - forkIO $ forever $ do (nr', line) - readChan; when (nr /= nr') $
putStrLn hdl line
This is fine assuming you always want to re-enter the loop. If you want
to loop conditionally (which is most often the case), forever isn't
going to work,
On Sat, 2009-03-07 at 23:12 +0100, Martijn van Steenbergen wrote:
Derek Elkins wrote:
Both are poorish style.
reader - forkIO $ forever $ do (nr', line) - readChan; when (nr /= nr') $
putStrLn hdl line
This is fine assuming you always want to re-enter the loop. If you want
to loop
Derek Elkins wrote:
If you are doing something else, use something else. This makes it
clear that you -aren't- going to break out (non-exceptionally), i.e. the
control flow is more obvious in this code than in the other versions.
Oh yes, of course! I wasn't saying forever is bad; in fact I
Two questions:
a) This chat server implementation doesn't actually close the connection
as a real one would need to do. If you use forever is there a way to end
the loop so as to end the connection?
b) In Section 5 of this paper:
http://www.cs.yale.edu/~hl293/download/leak.pdf
Comparing
Personally I would not use fix. I don't think it improves readability.
-- Lennart
2009/3/5 Daryoush Mehrtash dmehrt...@gmail.com:
In this chat server implementation
http://www.haskell.org/haskellwiki/Implement_a_chat_server
forkIO is used with fix as in:
reader - forkIO $ fix $
2009/3/6 Daryoush Mehrtash dmehrt...@gmail.com:
Two questions:
a) This chat server implementation doesn't actually close the connection
as a real one would need to do. If you use forever is there a way to end
the loop so as to end the connection?
Yes, throw an exception and catch it from
On Fri, Mar 6, 2009 at 1:48 AM, Daryoush Mehrtash dmehrt...@gmail.comwrote:
Question: Do I need to worry about space leak if I am using the fix to
instead of the let?
If you need to worry about a space leak with fix, you need to worry about it
with let.
The reason arrows can tie the loop
In this chat server implementation
http://www.haskell.org/haskellwiki/Implement_a_chat_server
forkIO is used with fix as in:
reader - forkIO $
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:.
fix $ http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:.
On Thu, 2009-03-05 at 15:36 -0800, Daryoush Mehrtash wrote:
In this chat server implementation
http://www.haskell.org/haskellwiki/Implement_a_chat_server
forkIO is used with fix as in:
reader - forkIO $ fix $ \loop - do
(nr', line) - readChan chan'
when (nr /= nr') $
On Thu, 2009-03-05 at 16:12 -0800, Jonathan Cast wrote:
On Thu, 2009-03-05 at 15:36 -0800, Daryoush Mehrtash wrote:
In this chat server implementation
http://www.haskell.org/haskellwiki/Implement_a_chat_server
forkIO is used with fix as in:
reader - forkIO $ fix $ \loop - do
Quoth Jonathan Cast jonathancc...@fastmail.fm:
You can certainly use let:
reader - forkIO $ let loop = do
(nr', line) - readChan chan'
when (nr /= nr') $ hPutStrLn hdl line
loop
in loop
But the version with fix is clearer (at least to people who have fix in
their
On Thu, Mar 5, 2009 at 6:27 PM, Donn Cave d...@avvanta.com wrote:
Quoth Jonathan Cast jonathancc...@fastmail.fm:
You can certainly use let:
reader - forkIO $ let loop = do
(nr', line) - readChan chan'
when (nr /= nr') $ hPutStrLn hdl line
loop
in loop
12 matches
Mail list logo