Skip to content

Commit e642d06

Browse files
committed
nice alternative!
1 parent 0393a98 commit e642d06

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Data/Uri/Query.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ initParserState xs = ParserState
3939

4040
data ParserError
4141
= NoParse
42+
deriving (Show, Eq)
4243

4344

4445

@@ -70,6 +71,23 @@ instance Alternative Parser where
7071
put s'
7172
pure y'
7273
Left e -> throwError e
74+
some f = Parser $ do
75+
s <- get
76+
case runParser' f s of
77+
Right (x, s') -> do
78+
put s'
79+
xs <- getParser $ many f
80+
pure (x:xs)
81+
Left e -> throwError e
82+
many f = Parser $ do
83+
s <- get
84+
case runParser' f s of
85+
Right (x, s') -> do
86+
put s'
87+
xs <- getParser $ many f
88+
pure (x:xs)
89+
Left _ ->
90+
pure []
7391

7492

7593
unlabeled :: PieceParser a -> Parser a

0 commit comments

Comments
 (0)