[Haskell-cafe] local loops

Per Larsson per at L4i.se
Tue Dec 14 11:16:24 EST 2004

I often use local loops in monadic code, e.g.

    main = do
     let loop = do 
              if cond then loop else return () 

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? 



More information about the Haskell-Cafe mailing list