
15 Jun
2017
15 Jun
'17
11:31 p.m.
There is another elementary alternative. If you need to treat C and D the same in just one place, you don't really have a problem. If you need to treat them the same in several places, do this: data T a b c = A a | B b | C c | D c -- existing type data Which a b c = A' a | B' b | CD Bool c which :: T a b c -> Which a b c which (A a) = A' a which (B b) = B' b which (C c) = CD False c which (D c) = CD True c then case which $ x of A' a -> B' b -> CD _ c -> ... If you want to merge the C and D cases often, I like this approach, otherwise the C c -> f c D c -> f c where f c = ... approach is better.