[Haskell-cafe] advantages of using fix to define rcursive functions

Janis Voigtlaender voigt at tcs.inf.tu-dresden.de
Thu Jul 26 03:43:28 EDT 2007


Donald Bruce Stewart wrote:
> 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.

> So actually, I suppose it is useful for small, anonymous recursive definitions.

It also exposes the recursive computation structure for direct
manipulation, enabling one to perform certain program
transformations/refactorings. Search for "fixpoint fusion" and "fixed
point promotion". While one might say: that's the business of a
compiler, actually existing ones are not very sophisticated in that
regard, so one might want to do such transformations "by hand"...

Ciao, Janis.

-- 
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:voigt at tcs.inf.tu-dresden.de




More information about the Haskell-Cafe mailing list