Re: [Haskell-cafe] local loops

14 Dec
2004
14 Dec
'04
5:04 p.m.
Per Larsson
I often use local loops in monadic code, e.g.
main = do ... let loop = do ... if cond then loop else return () loop
It seems that I can encode this idiom slightly more concise with the 'fix' operator (from Control.Monad.Fix), i.e.
main = do ... fix (\loop -> do ... if ...)
But is it really semantically equivalent? Is it as efficient?
Per
It is semantically equivalent. I don't know if it is as efficient; looking at the source code, I would expect GHC to inline fix anywhere it occurs, which yields your original version. Jonathan Cast
7463
Age (days ago)
7463
Last active (days ago)
0 comments
1 participants
participants (1)
-
Jon Cast