
On 18/08/2015, at 6:49 pm, Daniel Trstenjak
Hi Richard,
AND IT DOES NOT *CLAIM* TO CREATE A TYPE. It claims to state a type EQUALITY, and it really does.
I can understand your reasoning and only looking at 'type' it's fine, but you've to look at 'type/newtype/data' at once, and if 'data' is strangely named, what other name would you take for it?
Oh, I _have_ looked at them all at once. In fact looking at them all at once was precisely what made it easy to understand them. newtype *says* it introduces a new type, and it *does*. The distinction between type and newtype makes it extremely hard to be confused about 'type', or any rate hard to both be awake and *remain* confused for long. What name would I have used for 'data'? While 'newtype T x = T x' and 'data T x = T !x' _aren't_ exactly the same in Haskell, they _could_ have been, and then 'newtype' would have been the perfect replacement for 'data'. The fact that 'newtype' and 'data' *both* introduce new types is surely the one confusing point here. But again, this makes 'data' the confusing keyword, not 'type' and not 'newtype'. More precisely, we could have had something like newtype T x = ~T !x {- current newtype -} newtype C x = A | B x | C x x { - current data -} or some such distinction. But we have what we have, and it certainly isn't *more* confusing than F# or Clean. If this is the worst problem beginners have, Haskell must be in wonderful shape.
It's just like if you write
answer = 42
This does NOT define a new constant. It gives a new name for an existing value. Next thing someone will say that this ought to be written
value_alias answer = 42
or something.
But with this point of view 'type Sequence t = [t]' is also somehow bogus and should just be 'Sequence t = [t]'.
WRONG. Type names and function names live in different namespaces. 'type' is NECESSARY to specify the namespace that Sequence lives in.