Skip to content

Rework stdlib clones. #694

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

Draft
wants to merge 2 commits into
base: hidden-theory-items
Choose a base branch
from
Draft

Conversation

strub
Copy link
Member

@strub strub commented Jan 20, 2025

No description provided.

@strub strub self-assigned this Jan 20, 2025
@strub strub changed the title Reword stlib clones. Rework stdlib clones. Jan 20, 2025
The import mechanism is currently brittle, buggy, interact wrongly
with the cloning mechanism. Moreover, some declarations duplicate it
by reimplementing an ad-hoc, "non-import" mechanism. This commit fixes
this issues.
@strub strub force-pushed the hidden-theory-items branch from fdd7813 to fa18670 Compare January 20, 2025 12:33
@strub strub force-pushed the poly-better-clones branch from eeb3470 to 9f03146 Compare January 20, 2025 12:36
@strub strub requested a review from fdupress January 20, 2025 12:37
@strub strub force-pushed the poly-better-clones branch from 9f03146 to 0792c02 Compare January 20, 2025 14:06
@strub strub force-pushed the hidden-theory-items branch 2 times, most recently from 7066af3 to 6dfe829 Compare February 6, 2025 17:26
@vbgl
Copy link
Contributor

vbgl commented Feb 19, 2025

I can confirm that in this branch, it is possible to clone and use the PolyReduce.PolyReduce. Any chance to get it merged in the main branch?

Note that what I expected to be able to write was:

clone import PolyReduce.PolyReduce as P with
type coeff <= int,
theory Coeff <= Ring.IntID,
op n <- 256.

But that failed with

unknown symbol: Top.Ring.IntID.t

Workaround was to define my own IntID theory using

clone include Ring.IDomain with
  type t <= int,

when Ring.ec reads:

clone include IDomain with
  type t <- int,

@fdupress
Copy link
Member

I didn't review this because it was still draft, but happy to do so after it's rebased.

As a side note, given what we now know about how cloning works (and doesn't), perhaps it's time to emit a warning when the user clones a theory that does not contain modules and uses <- to instantiate things? (It would certainly help review this for thoroughness of the replacement.)

We could also (later) have a [final] option on clones, that deactivates the warning but prevents further instantiation—with a more meaningful error message than that currently emitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants