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 can definitely use the generics to eliminate the boilerplate. Your code is a textbook example why I (and many others never use the _
wildcard at top level). While it is tedious to write out all the cases, it is less tedious than dealing with the bugs.
In this happy example I would not only use Dave Hinton's solution but would slap an INLINE pragma on the auxiliary function f
.