-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use indexed applicatives #10
Comments
* The original `qtraverse` wasn't powerful enough to implement `qfoldMapDefault`. Using an *indexed* applicative makes it so. * Add `qfoldMapDefault`. * Adjust the type of `traverse_` to match. * Remove the surprising `QFunctor` superclass of `QFoldable`. Closes morphismtech#10
Oh yeah, I stole Joachim's answer or something like it to define the I'm not sure I agree that this is "the right way" to define
I disagree with this reasoning since the way
So there is no need to replace |
I don't see why you think so.
|
I don't think the analogy is strengthened for the reason I gave, Do you have a use case for traversing with Honestly, |
I realized my point 2 is wrong. In particular, data Pair c a b = Pair (c a b) (c a b) It really feels to me like You ask about why one might wish to traverse in an indexed applicative. The answer is the same as why you'd want to do anything in an indexed applicative. Generally, it's to maintain certain relationships between successive states, or something like that. To traverse in one, you need something (vaguely) How about I put it another way though: the indexed versions are pretty much guaranteed correct by the type checker. That gives you correct non-indexed ones for free! |
Indexed applicatives is a fascinating concept that I'd like to have a careful think about. An indexed monad, from the perspective of category theory, is a "category enriched in the monoidal category of endofunctors on Hask with monoidal product given by functor composition" where a monad is a "monoid object in the monoidal category of endofunctors on Hask with monoidal product given by functor composition" and an applicative is a "monoid object in the monoidal category of endofunctors on Hask with monoidal product given by Day convolution". Thus, an indexed applicative should be a "category enriched in the monoidal category of endofunctors on Hask with monoidal product given by Day convolution". I really think it's a worthwhile idea that probably belongs in another library, replete with example instances. |
I believe the right way to define
QTraversable
is using indexed applicatives. See some old SO questions I asked, and the answers:https://stackoverflow.com/questions/35123930/how-should-i-traverse-type-aligned-sequences
https://stackoverflow.com/questions/39135193/is-it-possible-to-reverse-type-aligned-traversals
Also, by the way:
https://stackoverflow.com/questions/30985070/how-can-i-express-foldr-in-terms-of-foldmap-for-type-aligned-sequences
The text was updated successfully, but these errors were encountered: