I have some types
data Foo = Foo
data Bar = Bar
data Baz = Baz
I want to use them as keys for a Map. Is this possible, and if so, how?
Additonal context below:
I have an application that builds VMs. I have seperated the work into Phases. Currently I have this type
data CurrentPhase = PHASEONE
| PHASETWO
| PHASETHREE (deriving Eq,Ord)
So far so good right, no problems like what I mentioned above. However, I made a type class to describe operations that are phase specific
class PhaseOps phase where
preValidate :: JobID -> phase -> Handler (Status)
doPreProc :: JobID -> phase -> Handler (Status)
updateConfig :: JobID -> phase -> Handler ()
postValidate :: JobID -> phase -> Handler (Status)
in order for this to work, I had to create a new set of singleton data types to use for PhaseOps instances.
data PhaseOne = PhaseOne
.. and so on
now I have these singleton types, and CurrentPhase. I'd like to get rid of CurrentPhase (which I am using for a Map with CurrentPhase being the key), and use my singleton data types.
data FooBarBaz = Foo | Bar | Baz? (Specifically, why doesn't this work?)PhaseOpslooks a great deal like a class that wants to be a record of functions instead.