type classes vs. multiple data constructors

Mike T. Machenry dskippy@ccs.neu.edu
Mon, 17 Feb 2003 01:44:07 -0500


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