-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Church-encoded Writer carrier #369
Conversation
newtype StateC s m a = StateC { runStateC :: s -> m (s, a) } | ||
newtype StateC s m a = StateC (s -> m (s, a)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops.
Tell w' -> do | ||
let !w'' = mappend w w' | ||
pure (w'', ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mappend
ing strictly here made for a ~2.5x improvement to the performance of this carrier in the benchmarks.
(w', a) <- runWriter (hdl (m <$ ctx)) | ||
let !w'' = mappend w w' | ||
pure (w'', (,) w' <$> a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly prefer BangPatterns
to seq
for these; plus, it turns out that we were inadvertently making listen
and censor
too strict.
This PR introduces and benchmarks a high-performance Church-encoded
Writer
carrier. In benchmarks where it wrapsIO
, it outperforms every other carrier by quite a decent margin.