
Oh, I disagree with this point of view. Circle is certainly a value, i.e. a full-fledged function, as Brian Beckman correctly surmised. The
Ben Rudiak-Gould wrote:
Brian Beckman wrote:
data Shape = Circle Float | Square Float
I read this something along the lines of "'Shape' is a type constructor, for use in other type-defining expressions, and 'Circle' and 'Sqare' are its two data constructors, which should be used like functions of type 'Float -> Shape'". Indeed, typing "Circle" at the Hugs prompt reveals that Haskell has a "function" named "Circle" with type "Float -> Shape."
Indeed, they are functions. Another way of thinking about it is as an "initial algebra" (technical term). What this means is this: "Shape" is a set of values that contains - the result of Circle x for all values x :: Float - the result of Square x for all values x :: Float such that - there's nothing in Shape that can't be reached this way ("no junk") - there is no value in Shape that can be reached in two different ways ("no confusion"). HTH. --KW 8-)