
26 Jul
2007
26 Jul
'07
3:29 a.m.
harald.rotter:
Hi,
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. -- Don