[Haskell-beginners] Does haskell have to have values?
mwm at mired.org
Wed Mar 23 21:17:57 CET 2011
I'm working my way through Real World haskell, and so far have found
the experience quite pleasant (though the harder exercises seem to
require things net yet covered).
Among the comments in the IO chapter was a discussion of whether or
not some monad was or was not a function, which got me thinking.
Values in haskell aren't evaluated until they're needed. They're
implemented as thunks, meaning they're roughly zeroadic functions that
will return the value when called.
The syntax of the language seems to make treating values as zeroadic
functions that return the value in question a reasonable
interpretation as a degenerate case:
(+) accepts two arguments and returns their sum.
(+ 5) accepts one argument and returns that plus 5.
(3 + 5) accepts zero arguments and returns 8.
or (more pedantically):
(+) accepts one argument and returns a function that accepts one
argument and returns a zeroadic function that returns the
value of the sum of the two arguments.
(+ 5) accepts one argument and returns a zeroadic function that ...
(3 + 5) a zeroadic function that returns 8
So the question is - is there any advantage or harm in this way of
looking at values?
Mike Meyer <mwm at mired.org> http://www.mired.org/consulting.html
Independent Software developer/SCM consultant, email for more information.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
More information about the Beginners