-
Notifications
You must be signed in to change notification settings - Fork 247
[ fix #577 ] generic n-ary functions and products #608
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
Conversation
Looks great! I should play around with it a bit and see if I can get any other useful things out. A generalised projection function for products would be incredible... |
Come to think of it, Edit: and there's still the case of your |
In order to define generic projections for n-ary products we need to be able to import `Data.Fin.Base`. It itself currently imports `Relation.Nullary.Decidable` which pulls all sorts of `Function.X` depending on `Relation.Binary.PropositionalEquality` and thus on n-ary product (because of generic congₙ and substₙ). This commit cleans up the dependencies of the modules involved in the cycle and splits off `Relation.Nullary.Decidable.Core` for simple definitions.
Let's also try to give a bunch of examples in a |
It makes more sense to call `map` the generalisation of the map corresponding to the reader monad. It will arrive really soon.
Note that its type will only be inferred if it is used in a context specifying what the type of the function ought to be. Just like the usual const: there is no way to infer its domain from its argument.
I'll develop a bit more later today (hopefully).
Hmm. I don't think that what I called FTR: ------------------------------------------------------------------------
-- holeₙ : ∀ n (k : Fin n) →
-- (A₁ → ⋯ Aₙ → B) → Aₖ₊₁ → A₁ → ⋯ → Aₖ → Aₖ₊₂ → ⋯ → Aₙ → B
-- As we have seen earlier, `cong` acts on a function's first variable.
-- If we want to access the second one, we can use `flip`. But what about
-- the fourth one? We typically use an explicit λ-abstraction shuffling
-- variables. Not anymore.
-- Reusing mod-helper just because it takes a lot of arguments:
hole₁ : ∀ k m n j → mod-helper k m n (j + 1) ≡ mod-helper k m n (suc j)
hole₁ = λ k m n j → cong {!holeₙ 4 (# 3) mod-helper!} {!!} -- argh!! Edit: never mind, got it (different definitions). |
There is no need to bother with Update because (for concrete natural numbers), touching the k-th argument can be done by only considering the function's type up to the (k-1)-th argument.
I don't mind it at all, quite the contrary. I came back to this PR multiple times |
It starts to feel like the module should be split up.
|
This is really wonderful stuff; I agree that the code is getting large, and that splitting things up as you suggest seems like a good idea. |
Ok, now that I have shipped my draft about this work (https://gallais.github.io/pdf/tyde19_draft.pdf), |
I'm annoyed by the module names:
|
Why not just |
https://agda.github.io/agda-stdlib/Data.Product.N-ary.html I was tempted to go for |
I would rename that one About |
If we do not mind a breaking change, we could move the existing |
Don't have a strong opinion. Happy with whatever you decide! |
I thought I had already committed the changes when I decided to amend them. But I |
By the way, nice TyDe draft. I very much enjoyed reading it. |
Thanks! |
Comes with documentation of the design decisions!