From b0f8af46ab1a89f107f2d678d17b765cd97ff59f Mon Sep 17 00:00:00 2001 From: ross Date: Fri, 21 Oct 2005 10:24:58 +0000 Subject: [PATCH] [project @ 2005-10-21 10:24:58 by ross] export parens, which is useful for writing Read instances. --- Text/Read.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Text/Read.hs b/Text/Read.hs index 16a4d15..bcb2d09 100644 --- a/Text/Read.hs +++ b/Text/Read.hs @@ -35,6 +35,7 @@ module Text.Read ( module Text.ParserCombinators.ReadPrec, L.Lexeme(..), lexP, -- :: ReadPrec Lexeme + parens, -- :: ReadPrec a -> ReadPrec a #endif #ifdef __GLASGOW_HASKELL__ readListDefault, -- :: Read a => ReadS [a] @@ -56,4 +57,14 @@ import qualified Text.Read.Lex as L lexP :: ReadPrec L.Lexeme lexP = lift L.lex + +parens :: ReadPrec a -> ReadPrec a +parens p = optional + where + optional = p +++ mandatory + mandatory = do + L.Punc "(" <- lexP + x <- reset optional + L.Punc ")" <- lexP + return x #endif -- 1.7.10.4