Inspired by @natefaubion’s work on making
parsing fast and stack-safe, I recently found the time to write uncurried-transformers, an almost-drop-in replacement for the transformers library that’s more performant and stack-safe.
I say almost drop-in as:
- Because the internal representation is different, actions defined in terms of the newtype constructors would have to be converted to use
MonadXoperations instead. For example,
ReaderT \r -> ...would become
asks \r -> ...
- The signatures for the runner functions are flipped. So instead of
runStateT action state, you’ll have to write
runStateT state action. This is mostly an opinionated choice, since I don’t think there’s a reason to keep the order introduced by Haskell’s record accessors.
Here’s a very rudimentary benchmark, showcasing a self-recursive
StateT action that counts up to a certain limit. It’s quite fast. Also, thanks a lot to Nate for walking me through the uncurried CPS approach, I’ve learned quite a lot implementing this library!