regex-applicative icon indicating copy to clipboard operation
regex-applicative copied to clipboard

Restriction(s) of reFoldl

Open treeowl opened this issue 10 years ago • 6 comments

The reFoldl interface is nice when you're happy with its "zero or more" semantics. If that's not cool with you, things get a bit ugly. Perhaps most importantly, "one or more" is a bit awkward to handle directly, and seems practically important. For example, a natural number is easily read by folding over one or more digits, but folding over zero digits will match everywhere you don't want.

treeowl avatar May 31 '15 22:05 treeowl

You can define reFoldl1 in terms of reFoldl in the same way as some is defined in terms of many.

UnkindPartition avatar Jun 01 '15 12:06 UnkindPartition

I know; I just think either reFoldl1 or some generalization thereof should probably be in the library for convenience. If you want a pull request, I can put one together.

treeowl avatar Jun 01 '15 13:06 treeowl

I don't feel strongly about this; feel free to do it if you want.

UnkindPartition avatar Jun 01 '15 14:06 UnkindPartition

I was mostly wondering if you had any ideas for a more general reFoldl restriction API.

treeowl avatar Jun 07 '15 05:06 treeowl

Not sure I understand. What do you mean by "restriction API"?

reFoldl is general enough to express this pattern, but a wrapper such as reFoldl1 can be added to make this simpler to use. What kind of generalization are you thinking about?

UnkindPartition avatar Jun 07 '15 05:06 UnkindPartition

I was thinking, vaguely, about whether there was something that would make "things like reFoldl1 easier to write. But I think you're probably right. I'll just put together a pull request for reFold1 itself.

treeowl avatar Jun 07 '15 08:06 treeowl