-
Notifications
You must be signed in to change notification settings - Fork 239
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
Add Effect.Foldable
and Data.List.Effectful.Foldable
implementation
#2300
Conversation
Two worries with this approach:
|
@Taneb thanks for the rapid feedback!
It's definitely DRAFT, but I appreciate the nudge to think about extensibility of the design.
In the first instance (sic), surely only a non-dependent one (see latest commits). In general, I might expect the design to evolve to embrace:
For sure, I've given much less thought to the |
Thinking about graded monoids feels like a long path that ends up with this PR never quite getting merged... and I don't want that. (e.g. for some types, the right kind of "monoid" might be a category). Actually, for The reason I asked about commutative structures is that the original reason I wanted I'm also going to point out the connection to #1962: |
@Taneb thanks for the feedback. I think I'm not clear whether what you are asking for (and proposing in #1281) was the haskell-style If the latter, that's a different kettle of fish (and yes, #1962 is one prototype attempt at it, that will probably need more rounds of design discussion; the/an alternative via Church encodings does, I think need to be investigated, not least because the library currently has no purely functional equivalent to If the former (which this PR is concerned with), then you may not immediately see a payoff for In either case, the development for indexed containers such as Reply about the comment on |
Two further comments on this evolving PR:
Regarding different potential equalities on |
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 guess my general comment is that this really is the fork in the road point. Do we want this to use instance arguments ala Haskell or do we not want to use instance arguments?
-- Basic instance: using supplied defaults | ||
|
||
foldableWithDefaults : RawFoldableWithDefaults {a} (λ A → Vec A n) | ||
foldableWithDefaults = record { foldMap = λ M → foldMap M } |
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.
Why would we want the version with defaults?
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.
Just for Vec
, or in general?
Re: the latter, I suppose I should have had a Foldable.Biased
module instead?
As to the "fork in the road", I hadn't intended to force such an issue (not sure I'd realised it might even be such). Given that progress on DRAFT status means we can/should have the discussion before proceeding... interested in seeing more! |
What am I missing? I'm seeing the word 'instance' all over the comments (and in the review) but none in the code? |
My bad, or at least, my possible misuse of the term-of-art when I should say something else, like 'dictionary'. In my mind, but not, I think (!?), unique to me, values of ... That said, it seems as though we have turned away from using actual |
AFAIK the policy is to define record values that can be used as instances but do not actually mark them with the |
Thanks @jespercockx ! |
Effect.Foldable
and Data.List.Effectful.Foldable
instanceEffect.Foldable
and Data.List.Effectful.Foldable
implementation
My take on this (with credit to Conor for making some of this clear): Haskell confuses two things, the idea of an interface, and the algorithm for giving implementations of that interface by search. So Haskell's typeclasses are the only mechanism for creating interfaces, which then push you into implicit resolution for implementations. That begets orphans, useless In Agda, record types are rich enough to act as interfaces. So while it is indeed tempting to call an actual record an 'instance', as Agda also has Haskell-style typeclasses, that just leads to confusion. So I think Agda-speak has evolved to only call 'instance' those things that use |
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.
Looking good.
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.
Looks great!
Not sure what's been going wrong with this merge? |
src/Effect/Foldable.agda
Outdated
open import Effect.Functor as Fun using (RawFunctor) | ||
|
||
open import Function.Base using (id; flip) | ||
open import Function.Endomorphism.Propositional using (∘-id-monoid) |
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.
Something went wrong here... should be Endo
since #2342 but my commit history on this branch had got out of sync somehow?
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.
Hopefully fixed now!
Fixes the deprecated module import i hope
Alternative approach to #1281 with specialised version(s) for
Data.List
. May solve #1099 ?Currently DRAFT, for discussion, esp. wrt:
Effect.*
, since ultimately it will be based offRawFunctor
)