
On Wed, 2008-10-15 at 13:01 -0700, Daryoush Mehrtash wrote:
I am having hard time understanding this statement:
Haskell types lack constructors, so the user never expects to be able to conjure up a value of an unknown type.
I am not sure how say in a Java language a constructor can "conjure up a value of an unknown type".
Well, that's the point. It can't, in Haskell or in Java. If you understand that --- that you can't call the default constructor of a class that is not statically known at compile time --- then there's no `gotcha', in Haskell or Java. The gotcha in Java is that every type that actually exists does in fact have a default constructor, and every type of the form Set<T> actually has a copy constructor, and so on. But if T isn't statically known at compile time, you can't call it, even though it's guaranteed to exist. In Java, even if I know nothing else about a class T, I know that Set<T> has a copy constructor. So I can get into the habit of calling the Set<T> copy constructor, without paying attention to whether T is statically known or not --- which breaks when T is a generic parameter. So Haskell lacks the `gotcha' because you never get into the bad habit of assuming every type has a constructor in the first place. jcc