Skip to content

Commit 3346419

Browse files
committed
Merge pull request #2 from purescript-contrib/char-update
Update for introduction of Char
2 parents 579ddbe + c5e021c commit 3346419

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Text/Parsing/StringParser/String.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Text.Parsing.StringParser.String where
22

3-
import Data.String (charAt, length, take, indexOf')
3+
import Data.Maybe
4+
import Data.String (charAt, fromChar, length, take, indexOf')
45
import Text.Parsing.StringParser
56

67
eof :: Parser Unit
@@ -10,8 +11,9 @@ eof = Parser (\s fc sc -> case s of
1011

1112
anyChar :: Parser String
1213
anyChar = Parser (\s fc sc -> case s of
13-
{ str = str, pos = i } | i < length str -> sc (charAt i str) { str: str, pos: i + 1 }
14-
{ pos = i } -> fc i (ParseError "Unexpected EOF"))
14+
{ str = str, pos = i } -> case charAt i str of
15+
Just chr -> sc (fromChar chr) { str: str, pos: i + 1 }
16+
Nothing -> fc i (ParseError "Unexpected EOF"))
1517

1618
string :: String -> Parser String
1719
string nt = Parser (\s fc sc -> case s of

0 commit comments

Comments
 (0)