[Haskell-cafe] advantages of using fix to define rcursive
Donald Bruce Stewart
dons at cse.unsw.edu.au
Thu Jul 26 03:29:31 EDT 2007
> I read about the usage of "fix" to define recursive functions. Although I
> think that I understood how to use "fix", I still wonder what the
> advantages of "fix" are (as compared to the "conventional" approach to
> define recursive functions).
> Any hints are appreciated.
There's no obvious advantage that I know of, other than being cute.
An example from xmonad:
allocaXEvent $ \p -> fix $ \again -> do
more <- checkMaskEvent d enterWindowMask p
when more again
So actually, I suppose it is useful for small, anonymous recursive definitions.
More information about the Haskell-Cafe