Ralf Hinze wrote:

 | Isn't this a consequence of parametricity?] `show []'
 | should produce `[]' and `show ""' should produce `""'.

Hi Ralf, take a look at the following example:

  data Bit = Low | High

  instance Show Bit where
    showsPrec _ Low  = showChar '0'
    showsPrec _ High = showChar '1'
  
    showList bits
      = showChar '<'
      . foldr (.) id (map shows bits)
      . showChar '>'

In Hugs:

  Main> [Low, Low, High, Low]
  <0010>

  Main> []
  ERROR: Cannot find "show" function for:
  *** expression : []
  *** of type    : [a]

  Main> [] :: String
  ""

  Main> [] :: [Bit]
  <>

I hope this convinces you.

Regards,
Koen.

--
Koen Claessen,
[EMAIL PROTECTED],
http://www.cs.chalmers.se/~koen,
Chalmers University of Technology.

Reply via email to