17 Feb
2003
17 Feb
'03
6:44 a.m.
I have a type that is as follows: data PlayerState = FugitiveState { tickets :: Array Ticket Int, fHistory :: [Ticket] } | DetectiveState { tickets :: Array Ticket Int, dHistory :: [Stop] } I have a few functions that act on PlayerState. move :: PlayerState -> PlayerState move DetectiveState ... = move FugitivieState ... = I was wondering if it's better to define them as type classes with the operations defined in the class. What do haskellian's do? Oh and if I say Instance Foo Baz where ... and only define a few of the operations in Foo... bdoes Baz take on some default methods? - mike