-
Notifications
You must be signed in to change notification settings - Fork 299
feat(data/{list/alist,finmap}): implicit key type #662
Conversation
Make the key type α implicit in both alist and finmap. This brings these types into line with the underlying sigma and simplifies usage since α is inferred from the value function type β : α → Type v.
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.
This is similar to the array
/ darray
module. Should we have a similar separation: finmap
/ dfinmap
? I think that would be easier to use.
If |
Why not make |
It has the benefit of being a functor and traversable. |
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.
make a separate dfinmap
and finmap
definition so that we can define a functor
and traversable
instance on finmap
@cipher1024 I'm not sure I follow. I believe you're referring to the following? structure d_array (n : nat) (α : fin n → Type u) :=
(data : Π i : fin n, α i)
def array (n : nat) (α : Type u) : Type u :=
d_array n (λ _, α) Given that, are you suggesting a restructuring to have the following? structure dfinmap {α : Type u} (β : α → Type v) : Type (max u v) :=
(entries : multiset (sigma β))
(nodupkeys : entries.nodupkeys)
def finmap (α : Type u) (β : Type v) : Type (max u v) :=
dfinmap (λ _ : α, β) In other words, the existing First, I'm guessing you're in favor of the implicit Second, does this alleviate the duplication of definitions and theorems for
Finally, I believe the above restructuring is orthogonal to this PR, and I'd like to push this through first. There are also a lot more things I'd like to add to the existing |
Yes that's what I'm suggesting.
Sure. After that, the functor instance should be simple enough. For the traversable instance, we should probably talk. |
@cipher1024 and @digama0 given that both of you approved this, I merged the PR. |
Thanks! |
* feat(data/{list/alist,finmap}): implicit key type Make the key type α implicit in both alist and finmap. This brings these types into line with the underlying sigma and simplifies usage since α is inferred from the value function type β : α → Type v. * doc(data/list/alist): alist is stored as a linked list
Make the key type
α
implicit in bothalist
andfinmap
. This brings these types into line with the underlyingsigma
and simplifies usage sinceα
is inferred from the value function typeβ : α → Type v
.