Let\'s consider a data type with many constructors:
data T = Alpha Int | Beta Int | Gamma Int Int | Delta Int
I want to write a function to che
You'll need to use a generics library like Scrap Your Boilerplate or uniplate to do this in general.
If you don't want to be so heavy-handed, you can use Dave Hinton's solution, together with the empty record shortcut:
...
where f (Alpha {}) = 0
f (Beta {}) = 1
f (Gamma {}) = 2
So you don't have to know how many args each constructor has. But it obviously still leaves something to be desired.