composewell / streamly

High performance, concurrent functional programming abstractions
https://streamly.composewell.com
Other
859 stars 65 forks source link

Rename "toFold" from the Parser module to unsafeToFold #2717

Closed harendra-kumar closed 2 months ago

harendra-kumar commented 8 months ago

This is a partial function as folds are less powerful than parsers, not all parsers can be safely converted to folds. However, folds converted to parsers can be safely converted back to folds.

adithyaov commented 2 months ago

Should we expose unsafeToFold I use it quite often when dealing with parsers.

adithyaov commented 2 months ago

The use of word unsafe is not required here. This is a partial function, just like head. Making all partial functions unsafe , removes the credibility of the unsafe keyword.