combine icon indicating copy to clipboard operation
combine copied to clipboard

Added `bind` to allow composition of parsers.

Open diasbruno opened this issue 6 years ago • 4 comments

Closes #45

diasbruno avatar Nov 06 '19 01:11 diasbruno

Unless I'm mistaken, pipe already handles this kind of composition, but in an unrestricted fashion, i.e. you can compose many parsers and only invoke the transformation function if all of them succeed. Nothing prevents you from using pipe with just a single parser though as an equivalent to what bind does here.

I'm not opposed to merging this as-is, but I'm wondering if you think there is a benefit to having both functions if they essentially overlap 1:1 in functionality?

bitwalker avatar Apr 04 '22 14:04 bitwalker

I didn't know pipe implemented this functionality. Maybe because bind is a common name for this, but if it does the job, we can close this.

Thanks!

diasbruno avatar Apr 12 '22 17:04 diasbruno

I'll try to have a look on the docs and see if we add something there.

diasbruno avatar Apr 12 '22 17:04 diasbruno

I looked at pipe and the only difference I can see is that it uses some arrays and a reverse...I don't know if it would be a good idea, but maybe we could implement pipe using bind and maybe remove the intermediary arrays of pipe. Any thoughts?

diasbruno avatar Apr 12 '22 17:04 diasbruno