on master help sign in
Get rid of dependency on `Text.Read.readMaybe` to resolve #382
6768b0eEvan Czaplicki
compiler/Parse/Helpers.hs+6−1
@@ -14,7 +14,6 @@ import SourceSyntax.PrettyPrint
14import SourceSyntax.Declaration (Assoc)
14import SourceSyntax.Declaration (Assoc)
15import Text.Parsec hiding (newline,spaces,State)
15import Text.Parsec hiding (newline,spaces,State)
16import Text.Parsec.Indent
16import Text.Parsec.Indent
17−import Text.Read (readMaybe)
18
17
19reserveds = [ "if", "then", "else"
18reserveds = [ "if", "then", "else"
20 , "case", "of"
19 , "case", "of"
@@ -50,6 +49,12 @@ iParseWithTable :: SourceName -> OpTable -> IParser a -> String -> Either ParseE
50iParseWithTable sourceName table aParser input =
49iParseWithTable sourceName table aParser input =
51 runIndent sourceName $ runParserT aParser table sourceName input
50 runIndent sourceName $ runParserT aParser table sourceName input
52
51
52+readMaybe :: Read a => String -> Maybe a
53+readMaybe s =
54+ case [ x | (x,t) <- reads s, ("","") <- lex t ] of
55+ [x] -> Just x
56+ _ -> Nothing
57+
53backslashed :: IParser Char
58backslashed :: IParser Char
54backslashed = do
59backslashed = do
55 char '\\'
60 char '\\'