johnynek / bosatsu

A python-ish pure and total functional programming language
Apache License 2.0
224 stars 11 forks source link

design for bosatsu libraries #1152

Open johnynek opened 7 months ago

johnynek commented 7 months ago
johnynek commented 7 months ago

If every library solves for a valid transitive set of public libraries then when adding dependencies, all diamonds are visible directly. So, if there is no collision in that list, you don't have a new diamond. If there is a collision, there is a set of candidate dependencies, and we can check each of those for all the N-1 others.

There should be a tool where we take the declared inputs, and then we generate the checked library output which would include the solutions to the current library, the previous version of the current library, and the hash of all the referenced libraries.

johnynek commented 7 months ago

We could make a projection of a dependency by taking the union of all imports. So, a library could have a projected inferface that it depends on. This goes in the direction of doing a full solution of the dependency problem, and in this view, the version numbers don't really matter except that they are ordered so we can identify which ones come later.

johnynek commented 7 months ago

Since when compiling, all diamond dependencies are solvable, that means the interfaces are compatible. So compiling each package isn't a problem. But once we have compiled and we are linking and emitting code, we need to know which version of the code we need to link to each package. We could merge them into a single namespace by appending an identifier for the version onto the names emitted when there is more than one, or we could use directories / package names.

Since ultimately, I'd like a C compilation target, it seems like appending versions to the names is the better approach.