Hi folks, I have been thinking a bit more about installed_theories for 1.0 version of the language, and this is what I think:
coq:lib
to see where the library is installed, eventually supporting COQPATH-boot
by default! That is to say, if we don't have (boot)
in scope, we docoqc -boot
so it won't auto-scan anythingcoq:lib
, then we add -R $coqlib Coq
and nothing for user-contrib
.(theories
declared, we find them as last resort in coq:contrib
and then we add -Q $contrib/theory_path theory
That should provide a good experience I think, WDYT?
When you find a theory in contrib/, how do you add its transitive dependencies?
For example, if we have:
(coq.theory (name a))
(coq.theory (name b) (theories a))
(coq.theory (name c) (theories b))
How do we make sure that c
adds -Q
for a
if both a
and b
are installed (rather than local).
Ahhh true :(
For 1.1 version we will have the meta data
So we need (unfortunately) to trade:
(legacy_transitive_theories ...)
until their deps are ported to Dunepick your poison
I have no issues with providing a reduced user experience for those that rely on coq makefile theories, but it's a real shame that we need to expose these sharp edges at all to those that stick to the dune only world.
I think we can only do that as a fallback
For people whose dep chain is fully dunerized we can do good, right?
we would only need to add the pain point for those that depend on non-dunerized deps
Yes, it is a shame, but can we do differently?
Emilio Jesús Gallego Arias: For people whose dep chain is fully dunerized we can do good, right?
I don't see how this can be done with installing the necessary metadata in the dune-package
Then let's pick poison number one, even in the form of having to add to theories manually
I think only a small subset of users will have to do that
and will actually motivate people to port packages people are using
so if your dep is not using dune yet
you need to add the required libs
that's a PITA, but still much better than today situation with make
I don't see how the poison is enough though. Even if the user is only relying on dune libraries, how does dune know the theory dependencies of installed theories?
let's start installing dune-package for Coq theories
Emilio Jesús Gallego Arias said:
that's a PITA, but still much better than today situation with make
Sure, that's because that's a very low bar
in fact we can even install in two places for now
I am assuming here we can't transition everything to dune at the same time
I think my assumption is correct
we need to provide a path
yeah, transitions are a big pain
Emilio Jesús Gallego Arias said:
let's start installing dune-package for Coq theories
Okay, but let's recall that this needs public names for lazy loading. E.g. so that when dune sees (theories foo.bar)
it knows that it must look into the package of foo
.
Or an alternative lazy loading scheme I suppose
Umm, I think we discussed not allowing that?
ah sorry, I'm confused
we need two fields I think
maybe that's the best (legacy_theories )
and (theories ..)
with a proper (theories pkg:foo.bar)
Yeah it is tricky to retrofit
The pkg:foo
syntax works fine. Just keep in mind that it introduces redundancies. E.g.:
(theories mathcomp:mathcomp)
(not that I care very much about that)
wouldn't that be (theories coq-mathcomp-ssreflect:mathcomp.ssreflect)
?
yeah it looks pretty large
ah yes, that's the full package name
but the package is named like that
and some packages like metacoq name the package different
I dunno
we can think of a nicer system
we could have just the package name mean all the theories?
but I dunno
I suppose it's not so bad if we allow people to immediately pull more than one theory:
(theories (:coq-mathcomp-ssreflect mathcomp.ssreflect mathcomp.foobar ..))
Yes, we have no idea how people will organize tho, now that they can
for example, my port of compcert uses a single one, but I'm sure compcert devs would modularize that
Sure, but note that they wouldn't be impacted by that. One can always omit the package name for theories in the dune project.
E.g. inside mathcomp itself, one does not need to qualify the packages as dune already knows that all the theories belong to a single project.
they are actually 5 opam packages tho
it still doesn't matter as dune has a package <-> theory map for every project
There is only one theory in user-contrib and that is user-contrib
I don't see any other way to support depending on user-contrib
We can at the same time introduce new installation layout for coq packages
We pass -Q user-contrib ""
to coqc and that's it
That way if you write a theory in your theories field dune can find it from the proper place with all the correct metadata
Here's another idea. It comes at the cost of making lazy loading less granular, and it doesn't work for private theories:
When trying to resolve mathcomp.foo
in:
(coq.theory
(name a)
(package c)
(theories mathcomp.foo))
We look into the dune-project
(or opam file) of the package c
. In particular, the depends
field. Then we eagerly load all the packages in that depends
field and resolve mathcomp.foo
from there.
Is it too late to go back to (public_name)?
It's not enough. Public names work because they introduce a restriction on library/theory names
E.g. theory foo(\.\alpha)*
must always live in package foo
.
Ali Caglayan said:
We pass
-Q user-contrib ""
to coqc and that's it
we can also pass -Q user-contrib/foo foo
and have more control, no?
How do rust or other large-scale build systems organize this?
are packages 1:1 to libraries?
Emilio Jesús Gallego Arias said:
are packages 1:1 to libraries?
I believe so
that could make sense for Coq too
maybe not
ummm
haha
i don't think it's such a bad idea tbh.
but note that users will still need to know about packages for plugins
Emilio Jesús Gallego Arias said:
Ali Caglayan said:
We pass
-Q user-contrib ""
to coqc and that's itwe can also pass
-Q user-contrib/foo foo
and have more control, no?
No because not every directory in user-contrib is a theory, some are multiple or even half. The only sound solution IMO is to treat the whole thing as a theory.
btw -Q user-contrib ""
is actually what Coq is doing last time I checked. We obviously want to do this with -boot however.
using more granular -Q for user-contrib does allow to fail when the user forgets deps and are installed, that's a big up for me. True, it allows the user to declare weird stuff for non-dunerized packages.
So I think that's a tradeoff
Summary of some possible rules:
Install
=======
1.0 version [for (package coq-foo) (theory Bar)]
lib/coq-foo/dune-package
lib/coq/user-contrib/Bar/Foo.v
1.1 version [for (package coq-foo) (theory Bar)]]
lib/coq-foo/dune-package
lib/coq-foo/Bar/Foo.v
Read
====
1.0 version [(theories Bar)]
will do -boot -Q lib/coq/user-contrib/Bar Bar
1.1 version [(theories coq-pkg1.Util coq-pkg2.Util)] ??
will do -boot -Q lib/coq-pkg1/Bar Bar -boot -Q lib/coq-pkg2/Bar Bar
=> error (likely)
2.0 version [(theories coq-pkg1.Util coq-pkg2.Util)] ??
will do -boot -Q lib/coq-pkg1/Bar coq-pkg1.Bar -boot -Q lib/coq-pkg2/Bar coq-pkg2.Bar?
This is the only real blocker to have a working dune setup for almost all Coq opam packages, hopefully we can implement it soon
I had a stab at implementing it over the holidays, but I ran into a few issues. It would be good to have a hacking session so we can discuss some of the difficulties I encountered.
One of the design issues at the moment is that the entire coq_lib logic relies on a theory coming equiped with basically a stanza. There are two ways we can go about changing this.
The first is a bit hacky but the second will require a lot more thought than I have been able to give it.
Since user-contrib files do not come with an associated dune or _CoqProject file we cannot really hold the hand of the user about setting up correct flags.
If I have a user-contrib theory A and a theory X that depends on A, then I have to match the flags in A (like -noinit, -indices-matter etc.)
That is perhaps a suitable cost for a user interested in doing advanced things like this so this is not a big worry.
A bigger worry would be how we partition user-contrib. If I have a theory that depends on say mathcomp
, then there is no way for us to make sure we really meant that or more specifically mathcomp.algebra
.
We can provide in the future, an alternative installation solution which has nice dune-package meta data using COQPATH or something. But that will require more future work.
My main worry with user-contrib is that we are trying to bend over backwards to support a flawed design, which makes our implementation more susceptable to bugs etc.
I'm still in favour of supporting it, but it is not easy so far.
Ali Caglayan said:
If I have a user-contrib theory A and a theory X that depends on A, then I have to match the flags in A (like -noinit, -indices-matter etc.)
no? It's perfectly possible to use a noinit library together with a yesinit library
also possible to give up on indices matter although likely to be inconsistent
regardless I don't see why dune would care
Even if it should, it can't for user-contrib I guess, so it's one less problem
I have in mind something much simpler like what is done for ocamlfind packages in the OCaml world, the infrastructure for "installed libs" is already there
but yes we gotta do a hacking session
Yeah, I agree with this. We should not reinvent the wheel: I would just define a Coq package to be an ocamlfind package containing a directory named coq-lib
(or something similar) inside. The corresponding entry in the META
file could then define both plugins and other Coq packages that are depended on.
I really think that before more hacking takes place, an installation format should be agreed upon (whether it is the one I hinted above, which I also think is what @Emilio Jesús Gallego Arias had in mind, or something else), so that we all understand where this is going.
I'd be happy to take part in a hacking session to discuss all this.
Yes, indeed as noted above there are two orthogonal things:
I want to do 1 first, then migration of many packages should provide a good base for the design requirements of 2.
Gaëtan Gilbert said:
Ali Caglayan said:
If I have a user-contrib theory A and a theory X that depends on A, then I have to match the flags in A (like -noinit, -indices-matter etc.)
no? It's perfectly possible to use a noinit library together with a yesinit library
also possible to give up on indices matter although likely to be inconsistent
regardless I don't see why dune would care
From the point of view of Dune, if a user is importing a library (say HoTT) and a file fails to be imported due to having different compilation flags, this error will not be very useful. What I was hoping was that Dune would step in and tell the user that the library has differing flags.
it will not fail to be imported
It will fail to get imported if I make a conflicting assumption to one in prelude. For example, reserving a notation level to be a different associativity.
does dune even check flag consistency across theory
stanzas today?
either way, I think we all agree this can't be in scope for user-contrib
since the info isn't there.
We don't check flag consistency, but it is something I would like to do, or at least make aparent to the user.
Last updated: Oct 13 2024 at 01:02 UTC