From 1f04286f201f1b552431c3766d732dff9f20fbcd Mon Sep 17 00:00:00 2001 From: Jamie Willis Date: Thu, 28 Jan 2021 19:00:31 +0000 Subject: [PATCH] semantic preserving fix for decide (#55) --- src/main/scala/parsley/combinator.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/parsley/combinator.scala b/src/main/scala/parsley/combinator.scala index b87095f19..598651ca3 100644 --- a/src/main/scala/parsley/combinator.scala +++ b/src/main/scala/parsley/combinator.scala @@ -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`.*/