Is there a way to mimic TypeScript's discriminated type unions in Haskell? I want to do the following:
data A = B | C | D
data W = X | Y | Z
data FinalType = A | W
I know the last definition will create two value constructors A and W for FinalType. I can make the FinalType correctly in the following way right now:
data FinalType = B | C | D | X | Y | Z
But this isn't very neat and gets annoying after a lot of value constructors are added. Is there a way to mitigate this in Haskell?