Skip to content

Commit 1f04286

Browse files
authored
semantic preserving fix for decide (#55)
1 parent d29d318 commit 1f04286

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/scala/parsley/combinator.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object combinator {
3333
}
3434

3535
/**`decide(p, q)` removes the option from inside parser `p`, if it returned `None` then `q` is executed.*/
36-
def decide[A](p: =>Parsley[Option[A]], q: =>Parsley[A]): Parsley[A] = decide(p).orElse(q)
36+
def decide[A](p: =>Parsley[Option[A]], q: =>Parsley[A]): Parsley[A] = select(p.map(_.toRight(())), q.map(x => (_: Unit) => x))
3737

3838
/**optional(p) tries to apply parser `p`. It will parse `p` or nothing. It only fails if `p`
3939
* fails after consuming input. It discards the result of `p`.*/

0 commit comments

Comments
 (0)