
Use Either A B from Data.Either:
http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Data-Eith...
On 14 December 2010 21:09, Russ Abbott
Is there a way to get this to work?
data A = Aconstructor Int data B = Bconstructor Int data AorB = A | B f :: Int -> AorB f x | even x = Aconstructor x | otherwise = Bconstructor x
I get this diagnostic.
Couldn't match expected type `AorB' against inferred type `A'
Since AorB is A or B, why is this not permitted? If instead I write
data AorB = Aconstructor Int | Bconstructor Int
everything works out ok. But what if I want separate types for A and B? Thanks, -- Russ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners