[Haskell-cafe] New Eq instance

Miguel Mitrofanov miguelimo38 at yandex.ru
Thu Aug 9 11:53:47 EDT 2007


rb> data Step = Step Id Scenario Action State Response

rb> instance Eq Step where
rb>   Step id1 scenario1 action1 state1 response1 == Step id2
rb> scenario2 action2 state2 response2 = id == id
rb>   _ == _ = False

"id == id" must be replaced with "id1 == id2".

Error message you've got might be confusing, since "id" is already
defined as an identity function, and functions are not Eq instances.

I'd suggest something like

data Step = Step {stepId :: Id,
                  stepScen :: Scenario,
                  steAction :: Action,
                  stepState :: State,
                  stepResp :: Responce}
instance Eq Step where step1 == step2 = stepId step1 == stepId step2



More information about the Haskell-Cafe mailing list