ollef / Earley

Parsing all context-free grammars using Earley's algorithm in Haskell.
BSD 3-Clause "New" or "Revised" License
361 stars 24 forks source link

satisfyMaybe :: (t -> Maybe a) -> Prod r e t a #47

Closed strake closed 4 years ago

strake commented 4 years ago

I find this useful and was surprised to not find it already defined.

ollef commented 4 years ago

Hey! Yeah, this seems useful! Can we come up with a more descriptive name? Perhaps there's a standard name used in other libraries that fits.

strake commented 4 years ago

I haven't seen it in many other parsing libraries (unfortunately), so we may be setting precedent. I guess that's all the more reason to choose a good name ☺

Regex-applicative calls it msym, but also has psym :: (a -> Bool) -> RE a a, so that name makes more sense there than it would here.

Otherwise the closest analog i have seen is Parsec's tokenPrim, but that's much more complicated.

How about satisfyMaybe?

ollef commented 4 years ago

Great, thanks for looking into it!