data A=A
data B=B
data AB=A|B
Which makes a sum type AB from A and B.
but the last line induces a compile error \"multiple declarations of
When you say data AB = A | B, you are not referring to the types A and B, but rather are defining data constructors A and B. These conflict with the constructors defined on the the previous lines.
If you want to create a type AB that is the sum of A and B, you must provide data constructors that wrap the types A and B, e.g.:
data AB = ABA A | ABB B