composewell / streamly

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

Add a Fold monad instance? #2718

Open harendra-kumar opened 5 months ago

harendra-kumar commented 5 months ago

Since Parser has a monad instance, Fold can also have one. We need to measure the performance and check at what point the direct style Fold/Parser monad becomes worse in performance compared to CPS. We can potentially have a static analysis tool to warn against heavier use of these.

Also, we can add a FoldK newtype wrapper over ParserK. If there is a significant difference in performance we can consider using a custom implementation of FoldK.