From ccc7548348fa0d5a10e4c795c5edc13d0dd3f014 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Wed, 7 Jul 2010 13:57:25 +0000 Subject: [PATCH] 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. --- GHC/Read.lhs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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} -- 1.7.10.4