Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Is bob a value, because it takes no parameter? Is it a function because f happens to be a function?

Functions are values. But not all values are functions. Functions are values with abstract type a -> a. That's what a function is in Haskell. (Of course, I'm only talking about functions from values to values here, not about functions from types to types and so on.)

Whether bob is a function or not will of course depend on its type. For instance, consider the following definition for f:

    f = (+ 5)
Then yes, bob will be a function, with type Num a => a -> a. On the other hand, if you decide to define f as

    f = take (10^10) $ [1..]
then it won't. The distinction here is determined entirely at compile time: it's about what type a particular value has.

> Therefore, "f = sum [1,2,3,4,5,6]" and "f = 21" are completely conceptually equal.

Right. They're both values of some concrete integer type.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: