diff --git a/bower.json b/bower.json index f89a733..7a6da73 100644 --- a/bower.json +++ b/bower.json @@ -20,21 +20,21 @@ "package.json" ], "dependencies": { - "purescript-arrays": "^5.0.0", - "purescript-either": "^4.0.0", - "purescript-foldable-traversable": "^4.0.0", - "purescript-identity": "^4.0.0", - "purescript-integers": "^4.0.0", - "purescript-lists": "^5.0.0", - "purescript-maybe": "^4.0.0", - "purescript-strings": "^4.0.0", - "purescript-transformers": "^4.1.0", - "purescript-unicode": "^4.0.0", - "purescript-generics-rep": "^6.1.1" + "purescript-arrays": "master", + "purescript-either": "master", + "purescript-foldable-traversable": "master", + "purescript-identity": "master", + "purescript-integers": "master", + "purescript-lists": "master", + "purescript-maybe": "master", + "purescript-strings": "master", + "purescript-transformers": "master", + "purescript-unicode": "master" + "purescript-generics-rep": "master" }, "devDependencies": { - "purescript-assert": "^4.0.0", - "purescript-console": "^4.1.0", - "purescript-psci-support": "^4.0.0" + "purescript-assert": "master", + "purescript-console": "master", + "purescript-psci-support": "master" } } diff --git a/src/Text/Parsing/Parser/String.purs b/src/Text/Parsing/Parser/String.purs index e916399..a5deb01 100644 --- a/src/Text/Parsing/Parser/String.purs +++ b/src/Text/Parsing/Parser/String.purs @@ -9,7 +9,7 @@ import Data.Array (many) import Data.Foldable (elem, notElem) import Data.Maybe (Maybe(..)) import Data.Newtype (wrap) -import Data.String (Pattern, length) +import Data.String (Pattern) import Data.String as S import Data.String.CodeUnits as SCU import Text.Parsing.Parser (ParseState(..), ParserT, fail) @@ -20,14 +20,14 @@ import Text.Parsing.Parser.Pos (updatePosString) -- | operations which this modules needs. class StringLike s where drop :: Int -> s -> s - indexOf :: Pattern -> s -> Maybe Int + stripPrefix :: Pattern -> s -> Maybe s null :: s -> Boolean uncons :: s -> Maybe { head :: Char, tail :: s } instance stringLikeString :: StringLike String where uncons = SCU.uncons drop = S.drop - indexOf = S.indexOf + stripPrefix = S.stripPrefix null = S.null -- | Match end-of-file. @@ -40,10 +40,10 @@ eof = do string :: forall s m. StringLike s => Monad m => String -> ParserT s m String string str = do input <- gets \(ParseState input _ _) -> input - case indexOf (wrap str) input of - Just 0 -> do + case stripPrefix (wrap str) input of + Just remainder -> do modify_ \(ParseState _ position _) -> - ParseState (drop (length str) input) + ParseState remainder (updatePosString position str) true pure str