Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"purescript-integers": "^4.0.0",
"purescript-lists": "^5.0.0",
"purescript-maybe": "^4.0.0",
"purescript-strings": "^4.0.0",
"purescript-strings": "^4.0.2",
"purescript-transformers": "^4.1.0",
"purescript-unicode": "^4.0.0"
},
Expand Down
12 changes: 6 additions & 6 deletions src/Text/Parsing/Parser/String.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand All @@ -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
Expand Down