
On Thu, Jun 2, 2011 at 10:03 PM, Christopher Howard
I'm trying to understand the Haskell type system, because it is portrayed as a rather powerful tool when properly harnessed. There are a few things, however, I could use some clarification on. For starters, I'm a bit confused about the "data" declarations:
I understand (correctly, I hope) that the purpose of a "data" declaration is to create a new type. So this makes sense:
data KeyValuePair = KeyValuePair String String
However, this also compiles:
data KeyValuePair a b = KeyValuePair String String
As well as does this:
data KeyValuePair a b = KeyValuePair String
And this:
data KeyValuePair a b = KeyValuePair
So you can see how I'm getting a bit confused?
Yes, 'data' declarations are for introducing a new type. Keep in mind that the type parameters (here 'a' and 'b') are not fundamental to the process - I can also declare
data MyType = MT Integer String
Maybe I can continue the discussion with a question: * Why should the above examples not compile? Then we can more deeply explore your confusion :-) Antoine
-- frigidcode.com theologia.indicium.us
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners