-
Notifications
You must be signed in to change notification settings - Fork 245
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
Define Algebra.Definitions.RawMonoid.sum
using Data.Vec.Vec
#1886
Comments
I'm guessing one of the motivations was: https://personal.cis.strath.ac.uk/james.wood.100/blog/html/VecMat.html#16679 |
Fair enough, but consider a simple equation that is used almost every day: In Agda, it would be something like this (given the same imports and declarations as in sum-++ : ∀ {m n} (xs : Vector A m) (ys : Vector A n) → sum (xs ++ ys) ≈ sum xs + sum ys I was surprised to find it absent in the stdlib, so I tried to prove it myself, and it took significantly more effort than it would have if we were to simply replace tail-++ : ∀ {m n} (xs : Vector A (suc m)) (ys : Vector A n) → tail (xs ++ ys) ≗ tail xs ++ ys
foldr-cong : ∀ f x {n} (xs ys : Vector A n) → xs ≗ ys → foldr f x xs ≡ foldr f x ys whose corresponding statements for |
I kind of feel like should be moved from |
There seem to be many possible competing choices/forces at work here:
But in the end, the stdlib in both its development history and its current state, represents a collective set of compromises and trade-offs, bearing the above forces in mind (along with individual stakeholders' commitments to minimalist/maximalist approaches to library design, in terms of module contents). As a volunteer effort, we rely on contributions in the form of PRs, and the subsequent, often lengthy, review/revision cycle. With a major (v2.0) milestone and library release forthcoming ('soon'), I could imagine there being some pushback in the short term to changing design decisions about implementation types for various library functions, especially if there is a performance hit on eg |
@jamesmckinna Thank you for your comment, it is very comprehensive and I haven't yet given thought to everything you've mentioned. Here is what I have thought about so far:
Actually it is not. As for the question where computations should live, I believe the answer to that depends much on what kind of abstraction and generalisation we want to introduce in the |
@XiaohuWang0921 thanks for your careful correction to my earlier message; my apologies for writing in haste without checking things carefully. For the general case of a
are still very much live, and interesting, topics for discussion. |
Comments on this:
For findability and usability by beginners, the specializations of the general algorithms should still exist and be exported - but be coded as specializations, not copies. |
Re: |
Is there a particular reason that the finite summation over a monoid is defined using
Data.Vec.Functional.Vector
, the functional definition for finite vectors, instead of the more natural choice of using the inductive definition fromData.Vec.Base
? If not, I think it should be rewritten using the inductiveVec
as the inductive definition allows pattern matching, which makes many properties of the finite summation easier to prove.The text was updated successfully, but these errors were encountered: