[Haskell-beginners] Re: Advice wanted on parallel processing

Colin Paul Adams colin at colina.demon.co.uk
Wed Mar 18 11:49:25 EDT 2009


>>>>> "Daniel" == Daniel Fischer <daniel.is.fischer at web.de> writes:

    Daniel> If e.g.

    Daniel> data Move = Move {from :: Position, to :: Position}

    Daniel> , the instance would be

    Daniel> instance NFData Move where rnf (Move f t) = rnf f `seq`
    Daniel> rnf t `seq` ()

    Daniel> That might require NFData instances for Position and its
    Daniel> components, but specifying these should be automatic.

<switched to beginners list>

Move is somewhat more complicated than that, but it comes down to
specifying instances for 

data Piece_colour 
    = Black
    | White  

and

data Piece_type 
    = Lance
    | Reverse_chariot 
    | Side_mover
    | Vertical_mover
    | White_horse
    | Rook 
    ... many more

which I'm not sure how to do. I tried added a deriving clause, but the
compiler complains:

  Can't make a derived instance of `NFData Piece_colour'
      (`NFData' is not a derivable class)
    In the data type declaration for `Piece_colour'

here I don't have and fields to force.
-- 
Colin Adams
Preston Lancashire


More information about the Beginners mailing list