From: simonpj@microsoft.com Date: Wed, 7 Jul 2010 13:57:25 +0000 (+0000) Subject: Partial fix for Trac #4136 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;ds=sidebyside;h=ccc7548348fa0d5a10e4c795c5edc13d0dd3f014;p=ghc-base.git Partial fix for Trac #4136 In 'choose' (which is a library function designed specifically to support derived instances of Read), we must match Symbol as well as Ident, for nullary constructors that (wierdly) are symbols. --- diff --git a/GHC/Read.lhs b/GHC/Read.lhs index f99e2df..b568287 100644 --- a/GHC/Read.lhs +++ b/GHC/Read.lhs @@ -314,10 +314,15 @@ choose :: [(String, ReadPrec a)] -> ReadPrec a -- ^ Parse the specified lexeme and continue as specified. -- Esp useful for nullary constructors; e.g. -- @choose [(\"A\", return A), (\"B\", return B)]@ +-- We match both Ident and Symbol because the constructor +-- might be an operator eg (:=:) choose sps = foldr ((+++) . try_one) pfail sps where - try_one (s,p) = do { L.Ident s' <- lexP ; - if s == s' then p else pfail } + try_one (s,p) = do { token <- lexP ; + case token of + L.Ident s' | s==s' -> p + L.Symbol s' | s==s' -> p + _other -> pfail } \end{code}