Tobias you replied at the same time I was answering, you did explained what is happening,
however, you said something which isn't right. As I mentioned before, "Type Constructors" and
"Value Constructors" are in different scopes, and so, their names can be used again...

if you don't believe me, give it a try with this example. I didn't even try it, but I asure you it
will compile without any trouble:

data A = C Int
data B = D Int

data AorB = A A | B B

Greeting,

Héctor Guilarte

On Tue, Dec 14, 2010 at 4:22 PM, Tobias Brandt <tob.brandt@googlemail.com> wrote:
On 14 December 2010 21:44, Russ Abbott <russ.abbott@gmail.com> wrote:
> What's confusing is that
>
>
> data AorB = A | B
>
> compiles with error.
> That raises the question of what it really means!

You have to distinguish between type and value constructors.
On the left hand side of a data declaration you have
a type constructor (AorB) and possibly some type variables.
On the right hand side you have value constructors followed
by their arguments (types or type variables). E.g.:

data TypeConstr a b c = ValueConstr1 a b | ValueConstr2 c | ValueConstr3 Int

But in your example A and B were already declared as type
constructors, so they can't be used again as value constructors.
That's why you get an error. If you remove

data A = ...
and
data B = ...

then

data AorB = A | B

compiles.

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners