I have a type
data Phase = PhaseOne
| PhaseTwo
| PhaseThree deriving Enum
and five operations to do on each Phase
readwritevalidateevalStatusupdate
I began trying to create a type class. The problem is, they are all the same type.
I’d like to be able to do something like
instance MyClass PhaseThree where
read a = ...
Also, I need to overload the return type.
I know type classes aren’t what I want. But I’m not sure how to do what I want. I thought
of a GADT but that’s not quite right as I need to be able to have each instance in a separate file.
I’d like some advice on which mechanisms I need to investigate? Have I given enough information?
I recommend inverting things a bit.
(or some similar rejiggering of classes into explicit records).