-
Notifications
You must be signed in to change notification settings - Fork 246
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
Association lists and their functions #2048
Comments
No answer to why there isn't (?) the companion As for association lists themselves, I'd be tempted to organise them under |
As to the question about API design, as a precursor to eventual implementation, should we consider more deliberately discussing those as separate issues/PRs/threads on the Zulip (under the #stdlib channel?) |
And now returning to the main question: how much of ... so if it does turn out to be possible to 'encode everything' that way, that doesn't stop it being independently interesting to consider versions specialised to lists of pairs, where the 'unary' predicate on pairs is induced by ... a binary, Boolean-valued function. Not least because, from a pragmatic point of view, for the hypothetical 'haskell-inclined, dependently-typed-curious' programmer, offering a (more shallow) stepped path from |
I think I forgot to post a reply here yesterday (I remember I wrote one 😬)
I missed that! Thanks!
I found a lot of such inconsistencies yesterday. For instance, starting with the insert, delete, and update operations,
insert : Vec A n → Fin (suc n) → A → Vec A (suc n)
remove : Vec A (suc n) → Fin (suc n) → Vec A n -- similar to _─_ in List
updateAt : Fin n → (A → A) → Vec A n → Vec A n
_[_]%=_ : Vec A n → Fin n → (A → A) → Vec A n -- this is updateAt, but as a mixfix operator
_[_]≔_ : Vec A n → Fin n → A → Vec A n -- overwrites the i-th element of xs with y _[_]%=_ : (xs : List A) → Fin (length xs) → (A → A) → List A -- similar to Vec, but does not have the updateAt function
_[_]∷=_ : (xs : List A) → Fin (length xs) → A → List A -- similar to Vec
_─_ : (xs : List A) → Fin (length xs) → List A -- similar to remove in Vec, but List does not have a remove function I'll start by making these 3 functions and their corresponding mixfix operators consistent. Reading your thoughts about association lists, I think it is more complicated to add them to Agda than I had initially thought 🙂 I read about association lists and if I understood your comments, association lists do not exist in Agda? So this would require formalising the idea and API of association lists in Agda before actually writing those functions. Let me update this issue to discuss only association lists. I will create another issue/PR for the |
To tidy up my ramblings: I don't think we implement As to the latter, I have in #1911 suggested that we take seriously the design of a suitable (for the dependently typed context) API for As to the former (and perhaps, in the context of the issue, against implementing association lists per se, but read on...) it occurred to me/I conjectured that, with sufficient ingenuity, the arbitrary But that might seem a 'what's the point?' question (is it interesting enough?) Except that, for didactic purposes, I think that a demonstration of the power of dependently-typed programming (via ADDED: Matthieu Sozeau's early paper (2008?) on finger trees in Coq might make a useful comparative case study...? |
See #1552 for a discussion of an aborted attempt of designing a similar interface for priority queues. |
Regarding @MatthewDaggitt 's comment: my own instincts are also towards a wide user-facing API, with a narrower implementor-facing API, not least because we are/have become more sophisticated about 'smart constructor' approaches to bootstrapping from narrow to wide... although I'm not immediately clear about how best to implement haskell type class-like default implementations, on a per-field basis (rather than monolithically) But in some sense, the API design question (and any subsequent PR) can (ought?), conceptually at least, be uncoupled from implementation... even if any particular experiment will probably ping-ping iteratively between the two! The challenge of collaborative software development might be to remain, as far as possible, as flexible/ego-less as regards API revision, as possible. Mind you, that's rich coming from me! |
So I looked at The main point of this issue is to ask: should agda-stdlib have association lists? That exact structure, rather than the wider question of designing a generic API for key-value stores. |
To go to things said way back at the start of this thread: I'm explicitly choosing to discuss this on issues here, so that there is written record of the discussion (and ultimately the results of that discussion) that can easily be searched in the future. I'm not sure if enough of the designers of stdlib spend enough time on the Zulip to have a 'better' conversation there. Ultimately, it is the quality of the conversation that matters most. |
@JacquesCarette thanks for the nudge use of the issue tracker for these open-forum discussions. Against myself, I perhaps even agree that the Zulip might not be the right place, although it (and other Zulip instances) is where I spend a lot of time online these days, outside my own contributions to development here. |
To the discussion topic then: my understanding is that we don't have association lists per se in the library. If they are to be added, I might think under
This, in turn, might generate, here or as a separate issue/PR, an API ... (oh, I can be very top-down as a designer, can't I?)... and once we agree, a PR implementing it. But then @MatthewDaggitt 's mention of #1552 and #1542 and earlier discussions about narrow/wide API design come to the fore... ... but would you (two; @JacquesCarette and @Saransh-cpp ) like to start the ball rolling? (no pressure, express or implied) |
Another one to punt until after v2.0, I think ;-) |
I would love it if we had (collectively) had time to pursue this discussion further, but suggest removing from the v2.1 milestone, at least, if not closing entirely...? |
I agree, this seems quite stale. I will have another student working on stdlib this summer. Still, this may not be the highest priority then either. |
I am currently looking to port
lookup
,lookupBy
,insertAt
, anddeleteAt
from Idris2, but I am not sure if they are exactly required in Agda. It does look like that they do not exist in Agda. If they should be added in, should the API oflookup
andlookupBy
stay the same, or should it be changed (given that I could not find any such pair of functions in Agda)? Thanks!The text was updated successfully, but these errors were encountered: