[Haskell-cafe] let and fixed point operator

Peter Verswyvelen bf3 at telenet.be
Thu Aug 30 15:18:30 EDT 2007


F# and Concurrent Clean introduced special syntax for doing this. Basically
they just invent new names for you.

In Haskell (warning: I'm a newbie, so take this with a grain of salt), I
guess you just use monads if you want to pass a value from one function to
another under some context, or you could just make your own little much
simpler combinator like:

infixl 0 \> -- I just took the first weird symbol combination that came to
mind, this does not mean anything (I hope ;-)

x \> fx = fx x

f x = x * scale \> \x ->
      x + transform \> \x ->
      g x

like this you don't have to invent new names, and you don't have to type
much more.

I'm sure this silly sequencing operator must already exist in the library
somewhere?

-----Original Message-----
From: haskell-cafe-bounces at haskell.org
[mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Peter Hercek
Sent: Thursday, August 30, 2007 6:18 PM
To: haskell-cafe at haskell.org
Subject: [Haskell-cafe] let and fixed point operator

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.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list