on master help sign in
Get rid of dependency on `Text.Read.readMaybe` to resolve #382
commit6768b0ef7a74264d59df5039ab11892b5ba3ebc4 authorEvan Czaplicki <info@elm-lang.org> dateWed 11 Dec 2013, 18:57 (13 years ago) parent1707e52
1 file changed+6−1
compiler/Parse/Helpers.hs+6−1
compiler/Parse/Helpers.hs+6−1
@@ -14,7 +14,6 @@ import SourceSyntax.PrettyPrint
1414import SourceSyntax.Declaration (Assoc)
1515import Text.Parsec hiding (newline,spaces,State)
1616import Text.Parsec.Indent
17−import Text.Read (readMaybe)
1817
1918reserveds = [ "if", "then", "else"
2019 , "case", "of"
@@ -50,6 +49,12 @@ iParseWithTable :: SourceName -> OpTable -> IParser a -> String -> Either ParseE
5049iParseWithTable sourceName table aParser input =
5150 runIndent sourceName $ runParserT aParser table sourceName input
5251
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+
5358backslashed :: IParser Char
5459backslashed = do
5560 char '\\'