[Haskell-cafe] let and fixed point operator

Peter Hercek peter at syncad.com
Thu Aug 30 12:17:37 EDT 2007


Hi,

I find the feature that the construct "let x = f x in expr"
  assigns fixed point of f to x annoying. The reason is that
  I can not simply chain mofifications a variable like e.g. this:

f x =
   let x = x * scale in
   let x = x + transform in
   g x

When one is lucky then it results in a compile error; in worse
  cases it results in stack overflow in runtime. The annoying
  part is figuring out new and new variable names for essentially
  the same thing to avoid the search/evaluation of the fixed point.

I suppose Haskell was designed so that it makes sense. The only
  usage I can see is like this:

let fact = \x -> if x == 0 then 1 else x * fact (x-1) in

   ... but that is not any shorter than:

let fact x = if x == 0 then 1 else x * fact (x-1) in

So the question is what am I missing? Any nice use cases where
  fixed point search is so good that it is worth the trouble with
  figuring out new and new variable names for essentially the same
  stuff?

Peter.



More information about the Haskell-Cafe mailing list