
On Tue, Aug 10, 2010 at 6:21 PM, Martijn van Steenbergen
On 8/2/10 7:09, Ertugrul Soeylemez wrote:
Given the definition of a Haskell function, Haskell is a pure language. The notion of a function in other languages is not:
int randomNumber();
The result of this function is an integer. You can't replace the function call by its result without changing the meaning of the program.
I'm not sure this is fair. It's perfectly okay to replace a call "randomNumber()" by that method's *body* (1), which is what you argue is okay in Haskell.
Nope. For example, suppose we have: int randomNumber(int min, int max); Equivalentely: randomNumber :: Int -> Int -> IO Int In Haskell if we say (+) <$> randomNumber 10 15 <*> randomNumber 10 15 That's the same as let x = randomNumber 10 15 in (+) <$> x <*> x If we had in C: return (randomNumber(10, 15) + randomNumber(10, 15)) That would not be the same as: int x = randomNumber(10, 15) return (x + x) Cheers! -- Felipe.