Skip to content
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

Implement Monadic Extensions/Rendering #117

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

emekoi
Copy link

@emekoi emekoi commented Jul 9, 2024

Closes #46.

I hadn't seen #74 until now, but it seems this is more or less the same idea. So most of the comments on it still apply. Instead of duplicating the API we could just expose the monadic interface, but I'm concerned that the usability for those not so familiar with monad transformers and the like, might suffer. However, I didn't want to break the existing API.

A couple of other things:

  • Names: I used the extension T on types and M on functions but maybe they should all just be M?
  • Comments: I think I updated them all and added basic ones for new functions, but maybe the comments for the pure interface and the monadic one should be switched?
  • Optimization: I tried benchmarking and I didn't see a noticeable performance difference (in fact, the benchmarks got faster so I might've done something wrong)
  • Alternative API: I also experimented with CPS encoding EndoM as (a -> m a) -> a -> m a in order to reassociate the binds so EndoM f <> (EndoM <> g <> EndoM h) doesn't end up as Endo (\x -> (h x >>= g) >>= f) but rather
    EndoM (\k x -> g (h (f k)) x). This seemed to be slightly faster (take that with a grain of salt) and might allow a *TransMAPI similar to the *RenderM API.
  • Tests: Since mtl is already a dependency, would some test using State, Reader, Writer, etc. be sufficient?

@emekoi emekoi changed the title Implement Monad Extensions/Rendering Implement Monadic Extensions/Rendering Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monadic blockRender?
1 participant