@Emilio Jesús Gallego Arias I noticed that you got rid of public names in the theory stanza. It's not an essential feature in dune, but it does have one important use on the OCaml side: whenever dune is unable to resolve a library foo
or foo.bar
, it knows to suggest the user to install package foo
. I find this hint to be quite important for users. Especially for those that are unfamiliar with the common opam packages and what libraries they provide.
For Coq, that would be the only use
in the current mode "coq lang 1.0" there is no notion of public name, the namespace is à la Haskell, global and modules are organized A.B.C.D
you have the package tho
but yeah that doesn't help a lot
problem is, in the 1.0 model, pkg1.A
and pkg2.A
do conflict
You could introduce a similar limitation on theory names. E.g. that theory foo
must belong to package foo
.
That would rule out all of the current Coq developments
I'm not sure how well received that may be.
IIUC
1.0 goal is to allow people to port their projects to Dune, IMHO
then we hope to do a 2.0 which is more principled
Ok well, then perhaps public names should make a return? Otherwise people will be stuck with randomly typing opam install
commands
I'd be great if they could make a return, but I can't see how they'd work
do you have an example?
the reality is that some people even use completely separate base names in the same package, e.g., a package foo
can have bar.qux
and qux.bar
I'm afraid people will be stuck with having to know what opam package to sue
many people don't even use opam in the coq wolrd
just to be clear, public names are going to be completely invisible to coq (like they are for OCaml)
what I mean is that you don't have the means to resolve them to anything meaningful
that's just a matter of populating dune-package metadata, no?
and they create a critical ambiguitiy, so that seems more of a misfeature to me
1.0 has to work with non-dunerized libs
I think 2.0 requires both more metadata and changes in Coq
When you say non-dunerized libs, in which direction do you mean:
1
and also 2. would be good, but that's less important, tho yes they can consume them as we keep the current layout for now
ok, then I don't see the problem. dune would install things in a way that makefile projects understand things. But when you use installed dune theories in other dune projects, you should use the public names.
how do you declare a dep from a dunerized Coq project to a non-dunerized one?
how is (theories pkg1.A pkg2.A)
resolved?
If the dune-project exists:
- Check if A is the list of defined theories
- If yes, use it. If no, complain that pkg1 doesn't have the theory
If it doesn't, use the fallback lookup for non-dunerized projects
what does 2 do that 3 doesn't?
we already do that
keep in mind that all coq theories are dumped together in user-contrib
in the 1.0, so indeed, other than for an opam hint, public_name is not useful
I suppose I missed the 4th. step. If both look ups fail, we can suggest the user to install pkg1
which seems like a useful hint.
you didn't consider the real problem up there, which is what to do with pkg2
as it is in conflict with pkg1
in the OCaml world, different packages go to different directories, this is not the case (yet) in Coq
Isn't that coqc's job though? To say that the conflict exists
so you lack injectivity of public names to locations and that's IMHO a dangerous thing
In OCaml, there's a similar problem with unwrapped libraries. One can try to use libraries that provide overlapping names but ocamlc will complain
but you still can solve it using -I
sorry, isn't there a bigger problem? opam
cannot help with unsatisfied deps in (theories pkg1.A pkg2.A)
...
in Coq, once you are there, you are boom
as both map to the same filesystem location
so you're talking of a future world where that's fixed, not of the present?
I'm talking about the present
in a future world, it is very clear that as the very minium, a coq package should install in lib/coq/$pkg
Paolo Giarrusso said:
sorry, isn't there a bigger problem?
opam
cannot help with unsatisfied deps in(theories pkg1.A pkg2.A)
...
yes, it can't help, but we want to design things so that it can help
not in lib/coq/user-contrib
Emilio Jesús Gallego Arias said:
in a future world, it is very clear that as the very minium, a coq package should install in
lib/coq/$pkg
Yes, that's obviously much better.
Rudi Grinberg said:
Paolo Giarrusso said:
sorry, isn't there a bigger problem?
opam
cannot help with unsatisfied deps in(theories pkg1.A pkg2.A)
...yes, it can't help, but we want to design things so that it can help
I'm afraid that as two packages can provide the same lib/coq/user-contrib/A.v
file, it is not possible to make this work well with the current lib model
Why can't we do that right away with dune? In other words, install to two locations:
Yes, that's the goal
for some time we thought of having two kind of (theories ...)
field
in fact, that's how 2.0 should be
one theories field for legacy libs, and a newer one for the 2.0 model, which should be specified before we start to implement IMHO
Emilio Jesús Gallego Arias said:
Rudi Grinberg said:
Paolo Giarrusso said:
sorry, isn't there a bigger problem?
opam
cannot help with unsatisfied deps in(theories pkg1.A pkg2.A)
...yes, it can't help, but we want to design things so that it can help
I'm afraid that as two packages can provide the same
lib/coq/user-contrib/A.v
file, it is not possible to make this work well with the current lib model
Yup, but why do we care? Opam will already forbid installations like this. The goal here is to introduce a naming convention that allows us to associate names with packages. Not to solve the installation directory issues
but given that the only advantage is the opam hint, and most people don't even use opam
I'm not sure it is a priority
seems to me to make a mess in the current state
non-injective package names are a bad bad thing
Rudi Grinberg said:
Emilio Jesús Gallego Arias said:
Rudi Grinberg said:
Paolo Giarrusso said:
sorry, isn't there a bigger problem?
opam
cannot help with unsatisfied deps in(theories pkg1.A pkg2.A)
...yes, it can't help, but we want to design things so that it can help
I'm afraid that as two packages can provide the same
lib/coq/user-contrib/A.v
file, it is not possible to make this work well with the current lib modelYup, but why do we care? Opam will already forbid installations like this. The goal here is to introduce a naming convention that allows us to associate names with packages. Not to solve the installation directory issues
how you you do that when the mapping is not injective, Im at a loss
Let me try to understand the issue. Today, I can define theories that will install to the same location on the file system, right?
Yes, but the theory name is injective
wrt to the install place
so you can reason much easier
if (name A) is already a theory, another one with the same name is an error
the check needs to be strenghenen by the way due to sub-theories
in the module namespace
(recurse dirs)
if you do (name pkg.A)
ok, you do that, but you will throw pkg away anyways
still the canonical name of the theory is A
not pkg.A
Okay, but even if you throw it away, it still served its purpose.
it has served a purpose, however now users are extremely confused
as when they write (theories pkg.A)
that's unclear
and then in the 2.0 layout you alluded to, where x.A
and y.A
would co-exist, it would even become more useful
yes in the 2.0 layout it would much better
but now seems like a way to shoot ourselves in the foot
because what does (theories pkg1.A pkg2.A)
mean?
Perhaps the .
syntax is overloading notation here. What if it was pkg:A
?
that's very confusing to users
even if it was pkg:A
what does the above mean?
that's a good point
the syntax, but even so it is confusing, and indeed, ambigous, so for sure that'd need a different syntax
in fact I had forgotten, but the reason I got rid of public_name was because it was not possible to determine
pkg:A
means that A
comes from pkg
- nothing more. Qualifying which package public artifacts come from is a good thing.
if pkg.A
meant module namespace pkg.A
or package pkg
module namespace A
Rudi Grinberg said:
pkg:A
means thatA
comes frompkg
- nothing more. Qualifying which package public artifacts comes from is a good thing.
it is a good thing, but for libraries using Coq Makefile
you have no idea, all you know is what it is in user contrib
so for example
module wasm.linear_register
could come from pkg compcert3
or from package compcert4
Yup, that's why I said there would be a fallback for coq makefile stuff to do the package-unqualified lookup.
as compcert is not using Dune
how do you know? All you can check is that the module lib/coq/user-contrib/wasm/linear_register.vo
is there
so that's IMHO a very bad experience to users
as they may write compcert4:wasm.linear_register
and maybe the module is coming from pkg compcert3
and Dune has not means to warn them
perhaps then you're only allowed to write compcert4:wasm.linear_register
if compcert4
is installed through dune?
that's what I meant above by using different fields, (legacy_theory ...)
and (theory ...)
of using the : syntax we don't need that
so yes that'd be great, but I planned for 2.0 version
we use %{pkg:foo}
elsewhere dune, but it's not very important
we could indeed do this for 1.0, at the cost of installing in both lib/coq/pkg
and lib/coq/user-contrib
, however I'm concerned about the size explosion, some Coq libs can reach the GiBs
For 2.0 I was planning to drop the constraint "non dunerized Coq libs can use dunerized Coq libs"
but we can do differently if we want
in dune, we kind of messed up the handling of binaries I feel. Nobody qualifies the package for the binaries they use and it makes it impossible to give good error messages and make sure people's dependencies are correct. I'd hate to see the same mistake repeated with coq.
Emilio Jesús Gallego Arias said:
we could indeed do this for 1.0, at the cost of installing in both
lib/coq/pkg
andlib/coq/user-contrib
, however I'm concerned about the size explosion, some Coq libs can reach the GiBs
Yeah, that could indeed be an issue.
I agree we can do better with deps, however Dune doesn't really know about packaging
so that's not easy, unless we add some package manager capabilities
which would be cool
Indeed it would be cool and it's a goal of ours.
Coq "2.0" version of the language is a good chance to do things better, because I'm positive we can also modify Coq
much more easy than OCaml
our CI model is already tailored to quicker evolution as we don't promise a lot of stability w.r.t. APIs
(we can't sadly)
But in general all you propose seems great, the thing is how to so we have a reasonable transient state where we can port the large number of Coq libs
Alright let's composition going then so people can port.
@Karl Palmskog composition is done :scream:
@Rudi Grinberg OK, how can I try out?
I've several projects where I've been waiting for it
https://github.com/ocaml/dune/pull/5784
I tried the PR branch on a project locally, whose packaging structure looks as follows (Dune is used in all packages):
coq-fourcolor coq-graph-theory-general
\ / \
coq-graph-theory-planar coq-graph-theory-ptt
Here, the base name is GraphTheory
, and then the subpackages are GraphTheory.general
, GraphTheory.ptt
, ...
I then added dune
like the following:
(coq.theory
(name GraphTheory.ptt)
(package coq-graph-theory-ptt)
(theories GraphTheory.general)
...)
Everything then works fine with dune build
. But when I build each opam package by pinning -k path
, I get the following error, which I thought the PR would fix:
#=== ERROR while compiling coq-graph-theory-ptt.dev ===========================#
# context 2.1.2 | linux/x86_64 | ocaml-option-flambda.1 ocaml-variants.4.13.0+options | pinned(file:///home/palmskog/src/coq/coq-community/graph-theory)
# path ~/.opam/4.13.0+flambda+coq.dev/.opam-switch/build/coq-graph-theory-ptt.dev
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p coq-graph-theory-ptt -j 15
# exit-code 1
# env-file ~/.opam/log/coq-graph-theory-ptt-393868-7c2c75.env
# output-file ~/.opam/log/coq-graph-theory-ptt-393868-7c2c75.out
### output ###
# File "theories/ptt/dune", line 5, characters 11-30:
# 5 | (theories GraphTheory.general)
# ^^^^^^^^^^^^^^^^^^^
# Theory GraphTheory.general not found
to me at least, the main benefit of "full composition" would be the possibility of using both dune build
on CLI for multi-package projects, and use dune
in opam packages...
@Karl Palmskog can you share the dune
file for graphtheory
you mean for coq-graph-theory-general
?
ye
yes
(coq.theory
(name GraphTheory.general)
(package coq-graph-theory-general)
(synopsis "Graph theory definitions and results in Coq and MathComp")
(flags :standard
-w -notation-overridden
-w -redundant-canonical-projection
-w -projection-no-head-constant
-w -duplicate-clear
-w -elpi.add-const-for-axiom-or-sectionvar
-w -ambiguous-paths))
what you wanna do worked fine in my branch
so yes it should work
I had a test for this effect, will push the test to Rudi / Ali branch
I have the following:
dune 3.2.0 pinned to version 3.2.0 at git+https://github.com/Alizter/dune#coq-compose
Yes it just seems the resolution code is not working inter-scope, that's an easy case
I can push a branch with the exact Coq+Dune code if you want.
I don't need that, maybe Rudi / Ali want
seems like an obvious bug tho
OK, then I leave up to @Rudi Grinberg if he wants more info
Could you make the workspace available somewhere?
Emilio Jesús Gallego Arias said:
what you wanna do worked fine in my branch
How did you resolve the name (theories GraphTheory.general)
when building against installed packages? AFAIK, this isn't the subject of composition, but the subject of making theories work identically whether they're installed or local.
@Karl Palmskog your example isn't meant to work yet. When I saw composition, what I mean is assembling as many independent dune projects into the same workspace for development and having everything "just work". It doesn't mean reading external theories properly (that's a separate limitation)
Rudi Grinberg said:
Emilio Jesús Gallego Arias said:
what you wanna do worked fine in my branch
How did you resolve the name
(theories GraphTheory.general)
when building against installed packages? AFAIK, this isn't the subject of composition, but the subject of making theories work identically whether they're installed or local.
I need to reconstruct the installed layout from user-contrib + COQPATH
Rudi Grinberg said:
Karl Palmskog your example isn't meant to work yet. When I saw composition, what I mean is assembling as many independent dune projects into the same workspace for development and having everything "just work". It doesn't mean reading external theories properly (that's a separate limitation)
Umm, ah, so @Karl Palmskog 's example is with installed theory?
I thought it was in the same workspace, otherwise I'm not sure how it is different
@Emilio Jesús Gallego Arias After the boot discussion, I remembered another reason why we need public names in dune. We rely on them for lazy loading. So for example, when we resolve the name foo
or foo.x
, we know we need to look up foo/dune-package
in the OCAMLPATH
. I don't think that's relevent to coq yet, but it's something to keep in mind.
Yes, but we have that IANM as the public name is pkg.name
Emilio Jesús Gallego Arias said:
Rudi Grinberg said:
Karl Palmskog your example isn't meant to work yet. When I saw composition, what I mean is assembling as many independent dune projects into the same workspace for development and having everything "just work". It doesn't mean reading external theories properly (that's a separate limitation)
Umm, ah, so Karl Palmskog 's example is with installed theory?
Yes, in his example, he's pinning some of the packages and installing them through opam
you need indeed to resolve the equivalent of findlib-installed libraries lazily, but that's fine as it is a tree
Yes, I missed that
yes, I'm using installed stuff through opam (by pinning). I thought this would be supported by full composition
Adding the installed stuff from opam is modular
so we can do a PR with workspace, inter-scope composition
and add a PR later on with support for installed_theories
That's a separate feature. If I understand how to do:
I need to reconstruct the installed layout from user-contrib + COQPATH
I should be able to implement it as well.
if that suits better the dev process
Rudi Grinberg said:
That's a separate feature. If I understand, how to do:
I need to reconstruct the installed layout from user-contrib + COQPATH
I should be able to implement it as well.
Yeah that's easy, modulo indeed the laziness, you don't want to scan user-contrib
in full, but only under demand
That scanning can become a hot-spot in large Coq projects
But with Memo.t , 3.0 has good support for that
Can you give me a pointer in the docs with the spec for user-contrib + COQPATH?
I need to go now sorry
but I will give you later if noone steps for that
user-contrib is basically $lib/coq/user-contrib
and COQPATH is just a list of dirs, split by colons
like OCAMLPATH
do you mean coq/user-contrib/$lib
?
and Coq merges all the dirs
nope
$lib/coq/user_contrib
all the libs are dumped there :S
here is the whole code, the last commit adds the theories
stuff: https://github.com/coq-community/graph-theory/tree/split-wagner+dune-composition
This use case is not really fringe, it's how I expect most mature Coq projects to use Dune eventually
$lib/coq/user-contrib/compcert/middle_end/bar.v
for example
Yes @Karl Palmskog it is not fringe, it is essential
but why do you put $lib
? it's always lib/coq/user-contrib
isn't it?
I mean, the basic use case
I mean $prefix/lib
for example, lib/coq/user-contrib/Ltac2
in my switch
except when you compose with Coq
sorry, I meant $lib for $prefix/lib
, that was a bad choice
It's gonna be awecome when we have this
then we can pretty much bump (using coq $version)
ok. so we can assume that $prefix/lib/coq/user-contrib/%{lib}
corresponds to a single library?
and start improving all that we discussed
@Rudi Grinberg yes a theory A.B.C is mapped to A/B/C.v
à la Haskell
user-contrib/%{lib}
can be used by several libraries (which have their own subdirectory under %{lib}
)
need to really go now, I'm so excited that's gonna be so cool
Ttyl. Perhaps Karl will help me understand meanwhile
I will do my best, but I don't understand too much about Dune internals.
You don't need to know anything about that. So given a theory A/B/C.v
, do you expect users to write (theories a.b.c)
to use it, right?
since C.v
is a file, I would expect to write (theories a.b)
They can also write (theories a)
to get a.* in scope
yes, in this case only a
and a.b
are possible
there is quite a bit of overlapping actually, there are some invariants that are not enforced by Coq actually
okay, but this is weird, isn't it? one can define the following in dune:
(coq.theory (name a.b))
(coq.theory (name a.c))
but then use the shared prefix a
as in (coq.theory .. (theories a))
?
yes, that's a common use case
it works that way
so individiaul packages can contribute to a "namespace"
like math-comp
that's powerful but not fully specified, another point to work for 2.0 version of the build language
It may be "powerful", but it's also completely opaque to package managers (as I've pointed out earlier).
in the Coq ecosystem, we try to enforce that two packages do not write to the exact same directory in user-contrib
, but there is no guarantee. It's pretty common though that packages write to a subdirectory defined by another package (e.g., there is the base mathcomp
directory, then mathcomp-finmap package writes .vo
files into mathcomp/finmap
to get mathcomp.finmap
name)
Rudi Grinberg said:
okay, but this is weird, isn't it? one can define the following in dune:
(coq.theory (name a.b)) (coq.theory (name a.c))
but then use the shared prefix
a
as in(coq.theory .. (theories a))
?
@Karl Palmskog what do you think about this? do you expect this to work? I don't think this works today with dune
Yes it is opaque, needs to be improved. But it is also common, think how haskell manages for example the Data.*
namespace
Emilio Jesús Gallego Arias said:
Yes it is opaque, needs to be improved. But it is also common, think how haskell manages for example the
Data.*
namespace
In Haskell, one writes the names of cabal packages in the cabal files, not the names of raw namespaces
Yes it doesn't work today, but I'm aware of the issue, not sure what to do tho, there are several issues
in my view, a single directory where you put .v
files should have a single coq.theory
name
declaration
so I was expecting to finish inter-scope composition, then grab what users are doing
are doing, real use cases
so I would not expect for it to be allowed to have a dune
file which says: (coq.theory (name a.b)) (coq.theory (name a.c))
.
@Karl Palmskog that's bizarre, that's basically how math-comp dune works
For now I think we can go ahead
with the current "strict" name treatment
until we can drop compat from Dune to non-dune, and use real packages
don't you put multiple dune
files in subdirectories in mathcomp itself?
Karl Palmskog said:
so I would not expect for it to be allowed to have a
dune
file which says:(coq.theory (name a.b)) (coq.theory (name a.c))
.
Okay, well what about this:
$ ls -R
A/ A/B A/C
$ cat A/B/dune
(coq.theory (name A.B))
$ cat A/C/dune
(coq.theory (name A.C))
And then you can use (theories A)
elsewhere?
Indeed @Rudi Grinberg you make a good point, about that stuff being specific to Cabal, if you don't use cabal you are in a different scenario
here we can (yet) switch everthing
@Rudi Grinberg yes, I would expect that to work
That's fine, see https://github.com/math-comp/math-comp/pull/316
but then use the shared prefix a as in (coq.theory .. (theories a))?
My guess is that we don't need to support that, but we need to port more developments to Dune
right, yes, the MathComp PR declares one coq.theory
per subdirectory. I was only saying a single dune
file with multiple coq.theory
would be an anomaly
A single dune file with several coq.theory is also fine
I guess I just don't see it as a sane feature at all. For example, someone might create some random theory (name a.b.c.d)
and now everyone that specified (theories a)
should be recompiled?!
tho not in all cases
Rudi Grinberg said:
I guess I just don't see it as a sane feature at all. For example, someone might create some random theory
(a.b.c.d)
and now everyone that specified(theories a)
should be recompiled?!
yes, as I say let's not support that for now
But indeed, we can't anticipate how people has structured thing
things
Back to making this work somehow, if we have a user-contrib as follows:
a/foo.v a/b/bar.v
do we let the users write a
and a.b
?
Since we have no idea if this came from a single theory a
or separate theories a
and a.b
?
currently, it's allowed to write a
and a.b
even if they (a/...
and a/b/...
) exist. But as per above, we try to avoid having packages that do this
didn't Emilio just say that mathcomp does this?
my view is that mathcomp writes disjoint subdirectories incrementally. It first creates mathcomp/ssreflect
, then mathcomp/algebra
, etc.
okay, but how should dune know that mathcomp
itself isn't a valid theory?
by the absence of a mathcomp/*.v
?
does it need to know that? if so, I'd go with absence of mathcomp/*.v
, yes
but I think Emilio wanted (theories mathcomp)
to work, even though there's no mathcomp/*.v
. This theories
declaration says you just depend on "whatever" happens to be in mathcomp
, recursively. I think this is sloppy, and I wouldn't do it, but fine by me if it's supported.
IMO, the only kind of names that belong inside (theories ..)
are those that were defined with (name ..)
somewhere.
this would be enough for me to get all my work done
but I can see Emilio's argument (I think) that it's more flexible to be laxer than that.
I also find it amusing that you think that including stdlib
in the theories field explicitly will impose on beginners, but this namespacing scheme will not :)
Karl Palmskog said:
but I can see Emilio's argument (I think) that it's more flexible to be laxer than that.
I think Emilio is reconsidering:
yes, as I say let's not support that for now
well, beginners will generally know the name of the third-party libraries they will use. They will use some boilerplate (theories ...)
for this given by someone else. But then they care about that particular library, and stdlib is something in the background that most people assume is there
Karl Palmskog said:
does it need to know that? if so, I'd go with absence of
mathcomp/*.v
, yes
Yes, it needs to know. Otherwise we're introducing differences between installed and local theories. For example, I might have (coq.theory (name mathcomp.foo))
locally, I can only use mathcomp.foo
, but now that it's installed, it's suddenly available as mathcomp
as well.
I suppose we could relax the meaning of the (theories ..)
field locally as well, but I don't think that's a good idea
@Karl Palmskog how should dune know where the user-contrib folder should come from?
I mean, I always assume it's known by the coqc
executable
wasn't there work to query coqc
for this?
It's known by the coq executable, but dune needs to know as well to add the appropriate dependencies.
I suppose there's coqc -config
, but it's kind of problematic to use it. Because now it means that we need a different code path when composing workspaces with coq itself.
I think I have used coqc -where
for some other tool
basically, it's assumed to be at:
echo `coqc -where`/user-contrib
but I have no idea if that's the recommended way to obtain the path
what happens when coqc
is part of the dune workspace?
no idea unfortunately, I always use Coq installed by opam or some other package manager like Nix
but I think very few Coq users will have Coq as part of their Dune workspace. Essentially only useful for Coq devs and plugin devs
In OCaml, we have opam setting OCAMLPATH for us
I'll just hard code it to ~/.opam/$switch/coq/lib/user-contrib
for now. Otherwise, users can set COQLIB
.
oof, I think that will break Nix
Why would it?
or maybe they actually set COQLIB
Nix handles user-contrib
some peculiar way I think
Actually, it's COQPATH
?
Karl Palmskog said:
Nix handles
user-contrib
some peculiar way I think
who do we ask about it?
maybe you can just go with what you proposed and Emilio can ping in some Nix expert and see if it affects them
I think coq_makefile
might be a guide to what the variables are usually called. For example:
COQLIB := $(COQMF_COQLIB)
and then COQMF_COQLIB
is defined by coq_makefile
during Makefile generation:
COQMF_COQLIB=~/.opam/$switch/lib/coq/
so I guess you could look at coq_makefile
for how it's "supposed" to be done.
the assumption is that people might want to redefine COQLIB
to something by setting env vars
Is COQPATH
documented somewhere?
I don't see any COQPATH
in stuff generated by coq_makefile
Rudi Grinberg said:
I'll just hard code it to
~/.opam/$switch/coq/lib/user-contrib
for now. Otherwise, users can setCOQLIB
.
Beware COQLIB
is one directory up so it would be $COQLIB/user-contrib
.
I don't know about any COQPATH, only COQLIB
At least internally, coqc is looking for packages in COQLIB if it exists.
So suppose I set COQLIB=foo
, coq should look up packages in foo/
or foo/user-contrib
?
foo/user-contrib
, as far as I know
And furthermore, stdlib in foo/theories
.
Here is coq's internal doc on that: https://github.com/coq/coq/blob/master/boot/env.mli
Karl Palmskog said:
this would be enough for me to get all my work done
(looks at the context) is it actually the case that packages use disjoint logical paths in -Q
options? you can't always split libraries to fix that (as you suggest) — you can only split foo
into foo.a
and foo.b
if there's no mutual dependency between them (e.g. foo.a
uses foo.b
or viceversa)
at least, I don't see how to specify mutual dependencies in the dune source language, while with coq_makefile
it is trivial (just specify multiple -Q
options in one _CoqProject
)
and I'd be happy to be wrong, since this is one thing ~I'll have to sort out~ at work (on our side) to complete our dune migration (okay wasn't _that_ hard)
is it actually the case that packages use disjoint logical paths in -Q options?
probably not, but I was talking about the projects I would conceivably use Dune for. Non-disjoint paths would be bad practice and thus not part of my projects...
ah, I thought you were wearing your coq-community hat
people who want some strange -Q/-R options will still have coq_makefile, etc. But in the coq-community GitHub org, for example, we will make sure to use best practices for building, including disjoint -Q. So if Dune even goes so far as mandating that, that's fine by me...
Indeed I think that (theories mathcomp)
should not work, even if it will work for a while "by accident"
What happens when a theory with boot
is in scope is a good question
I guess in this case installed_theories
should be empty
so no lookup
We don't really need -open
I think, we already have -R
, maybe we should enforce it is only used in the current compilation unit
@Emilio Jesús Gallego Arias "-open" has much more sane semantics than "-R" IMO
It is already massively confusing for users (and me) to have -R and -Q around.
At least with "-open" (not particularly happy with the name but oh well) it is obvious that the loadpath is not being modified.
-Q has a simple modification to the loadpath
-R can do whatever and that is really tricky to treat in tooling
Here is something that happens today: -R and -Q can be interleaved many times, and their order between each other matters.
-R exists as a convenience to users. We should support a proper convenience "-open" and stop using -R in tooling all together.
Emilio Jesús Gallego Arias said:
I guess in this case
installed_theories
should be empty
What's the installed_theories
field is about?
@Ali Caglayan yes, the first we should do is to restrict -R to a single invocation, and enforce the invariant that the file passed to coqc
is actually scoped by -R
I just meant we can reuse the option
Still the non-commutativity of -R and -Q remains.
I suggest restricting -R as you say, or even go as far as deprecating it.
The alternative should be a properly implemented -open
Here we have a choice, do we want to be able to -open multiple theories?
I think that would not be a good idea
In what sense?
In what sense does the non-communitativy remain? You mean after fixing it, or before
For instance today, the Coq stdlib and typically the current development are "-open"ed.
Yes, the first needs to be fixed
-R really means -open, I find -open confusing as this is not OCaml where you do open Foo
Coq actually has better semantics than OCaml
You can have -Q A/B Foo
and -R A Bar
which changes the semantic
Keeping -R is OK as for a lot of users it will keep working
@Ali Caglayan that should error
Another very unfortunate thing -R does today is to flatten the namespace beyond open
that should be fixed
No error, only a warning.
Stdlib is prime offender, but adding From Coq would alleviate it, as in this case the wildcard is explicit
Not in the stdlib tho
We shouldn't have to use From Coq in the stdlib
Ali Caglayan said:
No error, only a warning.
I don't see that as a sane semantics, IMHO it should eventually error, again it breaks injectivity which is very bad (means you can't maintain proper reverse maps for example)
I mean stdlib users
Emilio Jesús Gallego Arias said:
Ali Caglayan said:
No error, only a warning.
I don't see that as a sane semantics, IMHO it should eventually error, again it breaks injectivity which is very bad (means you can't maintain proper reverse maps for example)
I'm not suggesting that, that is what happens today.
they can write Require List
where they mean Require Lists.List
etc...
Yes what happens today is not good at all
it is a mess
I don't think anyone disagrees on the current state needing work
Here is a proposal for the semantics of -open
or whatever we want to call it:
Require Import
in a file, I should decorate it to From ... Require Import
. The From to use is whatever was passed to -open.We should have all Require Import's use From internally
Keeping the name -R for such an option is dumb IMO, since it means "Recursive" and it is not even that anymore.
what if I use Require
with a full path?
and I guess you're assuming a single -open
That semantics seem too weak to me
It may be dumb, but if that keeps compat with a lot of 3rd party developments, that's dumb but a great time saver
-open
is again not a very good name, as we don't "open" things in Coq
hmm, isn't "Import" quite close to the SML "open"? [Semantically]
I don't know, I would be surprised if it were
at least, implementation wise
anyways my point is that it is not opem
indeed, -open means something more like "import"
By the way @Rudi Grinberg , turns out that jsCoq for example does already maintain a map from Coq modules to the corresponding package that is implemented it. This is used for lazy downloading of theories, but indeed, that could be useful for Dune too.
The main problem is that it is a kind of global database, in the sense that it is hard for Dune to know that (theories bar)
maps to some package. If the user already knows to write (theories pkg:bar)
indeed they have already done the hard part of the work themselves, which to resolve the module to the package, haven't they?
Yes, that's exactly it. I don't think it's a very big burden either
Last updated: Jun 03 2023 at 15:31 UTC