diff --git a/src/Text/Parsing/StringParser/String.purs b/src/Text/Parsing/StringParser/String.purs index 254fab9..f70712a 100644 --- a/src/Text/Parsing/StringParser/String.purs +++ b/src/Text/Parsing/StringParser/String.purs @@ -1,6 +1,7 @@ module Text.Parsing.StringParser.String where -import Data.String (charAt, length, take, indexOf') +import Data.Maybe +import Data.String (charAt, fromChar, length, take, indexOf') import Text.Parsing.StringParser eof :: Parser Unit @@ -10,8 +11,9 @@ eof = Parser (\s fc sc -> case s of anyChar :: Parser String anyChar = Parser (\s fc sc -> case s of - { str = str, pos = i } | i < length str -> sc (charAt i str) { str: str, pos: i + 1 } - { pos = i } -> fc i (ParseError "Unexpected EOF")) + { str = str, pos = i } -> case charAt i str of + Just chr -> sc (fromChar chr) { str: str, pos: i + 1 } + Nothing -> fc i (ParseError "Unexpected EOF")) string :: String -> Parser String string nt = Parser (\s fc sc -> case s of