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?
[x] 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?
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:
T
on types andM
on functions but maybe they should all just beM
?EndoM
as(a -> m a) -> a -> m a
in order to reassociate the binds soEndoM f <> (EndoM <> g <> EndoM h)
doesn't end up asEndo (\x -> (h x >>= g) >>= f)
but ratherEndoM (\k x -> g (h (f k)) x)
. This seemed to be slightly faster (take that with a grain of salt) and might allow a*TransM
API similar to the*RenderM
API.mtl
is already a dependency, would some test usingState
,Reader
,Writer
, etc. be sufficient?