[Haskell-cafe] class-instance

Patrick Browne patrick.browne at dit.ie
Mon Jan 17 12:33:47 CET 2011


-- My intension is that the PERSON class should *specify*
-- that a person has a constant id called p1
-- and that a person has a name that can be found from the id.
class PERSON a b where
  p1 :: a
  name :: a -> b

-- My intension is that the instance should  implement the PERSON class
instance PERSON  Int String where
  p1 = 1
  name p1 = "john"

-- 
-- Why does the evaluations of p1 or name p1 produce errors?
-- how do I fix them and still keep the basic instance-implements-class
relation?
-- Thanks,
-- Pat

This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie



More information about the Haskell-Cafe mailing list