Skip to content

Read Char instance, for [Char], and ['a', 'b'] syntax

Haskell 98, in section 10.4, states:

readsPrec will parse any valid representation of the standard types apart
from strings, for which only quoted strings are accepted

hugs follows this:

Hugs.Base> read "['a', 'b']" :: String
"
Program error: Prelude.read: no parse

while GHC ignores it:

Prelude> read "['a', 'b']" :: String
"ab"

The GHC libraries source shows that this is a wilful variation from H98:

  readListPrec =
    parens
    ( do L.String s <- lexP -- Looks for "foo"
         return s
     +++
      readListPrecDefault   -- Looks for ['f','o','o']
    )               -- (more generous than H98 spec)

I do not see the point of this inconsistency, so I believe we should consider changing it for Haskell'.

Trac metadata
Trac field Value
Version
Type Task
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component HaskellPrime
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information