Skip to content

Commit

Permalink
semantic preserving fix for decide (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mie6 authored Jan 28, 2021
1 parent d29d318 commit 1f04286
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/parsley/combinator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object combinator {
}

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

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

0 comments on commit 1f04286

Please sign in to comment.