summaryrefslogtreecommitdiff
path: root/libraries/base/Text
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2012-12-21 17:40:08 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2012-12-21 17:40:08 +0000
commite1779a71cf9bdfcac6e9cc8d9eb0b8763060954b (patch)
tree1225feae0aa9eb12b8ed322445bbcb6c746fd438 /libraries/base/Text
parenta18cf9cbdfec08732f5b7e0c886a5d899a6a5998 (diff)
downloadhaskell-e1779a71cf9bdfcac6e9cc8d9eb0b8763060954b.tar.gz
Define GHC.Read.expectP and Text.Read.Lex.expect
They are now used by TcGenDeriv
Diffstat (limited to 'libraries/base/Text')
-rw-r--r--libraries/base/Text/Read/Lex.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/libraries/base/Text/Read/Lex.hs b/libraries/base/Text/Read/Lex.hs
index f5a07f1658..8a64e21b80 100644
--- a/libraries/base/Text/Read/Lex.hs
+++ b/libraries/base/Text/Read/Lex.hs
@@ -22,7 +22,7 @@ module Text.Read.Lex
, numberToInteger, numberToRational, numberToRangedRational
-- lexer
- , lex
+ , lex, expect
, hsLex
, lexChar
@@ -144,6 +144,11 @@ numberToRational (MkDecimal iPart mFPart mExp)
lex :: ReadP Lexeme
lex = skipSpaces >> lexToken
+expect :: Lexeme -> ReadP ()
+expect lexeme = do { skipSpaces
+ ; thing <- lexToken
+ ; if thing == lexeme then return () else pfail }
+
hsLex :: ReadP String
-- ^ Haskell lexer: returns the lexed string, rather than the lexeme
hsLex = do skipSpaces