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

Missing case for Constraint for fmap and <*> #62

Open expipiplus1 opened 1 year ago

expipiplus1 commented 1 year ago

Ahh! This is actually annoying for passing in monadic/user state to the productions because if we put the constraining function inside a Prod (as is done for Many and Alts) then we can't discover the nulls without the user state, and hence can't use user state for avoiding rerunning the grammar!

ollef commented 1 year ago

Oof. Can you see a way to implement it? Might have to be removed.

expipiplus1 commented 1 year ago

As it is, the constraint production can't remain at the same type, because without a Prod which is positive in the eventual Constraint type we have nowhere to push <*> into.

The constraint function however wouldn't need to change as it could easily forward to Constraint myProd (Pure myPredicate)