-
Notifications
You must be signed in to change notification settings - Fork 65
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
MonadAccum #109
MonadAccum #109
Conversation
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.
WIP, needs some expanded docs, but otherwise LGTM
Control/Monad/Accum.hs
Outdated
-- | ||
-- [Zero and plus:] None. | ||
-- | ||
-- [Example type:] @'Accum' 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 actually kind of like this doc style. 👍
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.
Can't claim any credit here. I'm just using what already existed for (at least) MonadCont
.
-- 1. @'accum' ('const' (x, 'mempty'))@ @=@ @'pure' x@ | ||
-- 2. @'accum' f '*>' 'accum' g@ @=@ | ||
-- @'accum' '$' \acc -> let (_, v) = f acc | ||
-- (res, w) = g (acc '<>' v) in (res, v '<>' w)@ |
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 would name these laws:
[Pure-Quot]
(in the sense ofpure x
being quotiented with(x, mempty)
)[Const-Accum]
because it is what it says it is.
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.
We'd need to name all the others too, then. Good idea though.
I guess you're aware of #89, on which I took a break because I didn't quite get how the docs were supposed to be structured. |
And, I should add, I can finish #89 if that saves you work & brain capacity. |
@turion At this point I'm nearly done anyway - I just have some docs to add and that's it. But thanks for offering! |
This defines a type class, along with a helper
DerivingVia
type, a bunch of instances, documentation and laws, to address the corresponding entry in #86.This is WIP for now, as I want to add some details about the meaning of the various instances, which may not be 100% obvious to a first-time reader.