Skip to content
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

refactor: Add a hugr-core crate #1108

Merged
merged 9 commits into from
May 28, 2024
Merged

refactor: Add a hugr-core crate #1108

merged 9 commits into from
May 28, 2024

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented May 24, 2024

Moves all the code from hugr into a hugr-core subcrate.
This way, hugr-passes (and any other new subcrate) can depend on the core definitions and get reexported in hugr.

This PR does not. Change any definition or visibility in the code, as the renamed files are noisy enough.
In particular, having hugr-core will let us unseal HugrInternals and HugrMutInternals so they can be used in tket2, but that's work for another PR.

As a bonus, #1100 is no longer a breaking change since we can re-export the library without a cyclic dependency.

Closes #294

@aborgna-q aborgna-q requested a review from a team as a code owner May 24, 2024 13:17
@aborgna-q aborgna-q requested a review from zrho May 24, 2024 13:17
Copy link

codecov bot commented May 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.49%. Comparing base (9ff6dce) to head (0f64d28).

Current head 0f64d28 differs from pull request most recent head dc4341b

Please upload reports for the commit dc4341b to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1108      +/-   ##
==========================================
- Coverage   86.78%   86.49%   -0.29%     
==========================================
  Files          90       90              
  Lines       18549    18502      -47     
  Branches    18156    18109      -47     
==========================================
- Hits        16098    16004      -94     
- Misses       1606     1656      +50     
+ Partials      845      842       -3     
Flag Coverage Δ
rust 86.57% <100.00%> (-0.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aborgna-q aborgna-q requested review from ss2165 and removed request for zrho May 24, 2024 13:46
@@ -260,15 +260,15 @@ impl TypeEnum {
///
/// Examples:
/// ```
/// # use hugr::types::{Type, TypeBound};
/// # use hugr::type_row;
/// # use hugr_core::types::{Type, TypeBound};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

examples should not mention hugr_core

Copy link
Collaborator Author

@aborgna-q aborgna-q May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0f23521.
Note that example lines starting with a # are not rendered in the docs, so we don't care whether they use hugr or hugr_core.

@aborgna-q aborgna-q requested a review from ss2165 May 28, 2024 10:27
//! use hugr::types::FunctionType;
//! # use hugr_core::Hugr;
//! # use hugr_core::builder::{BuildError, BuildHandle, Container, DFGBuilder, Dataflow, DataflowHugr, ModuleBuilder, DataflowSubContainer, HugrBuilder};
//! use hugr_core::extension::prelude::BOOL_T;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these have # in front of them

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed module-level docs when searching for examples...

I think these give a bit of context to the example below, so it's fine to have them explicit.
I changed all hugr_core:: uses for hugr::, to avoid further confusions.

@@ -0,0 +1,163 @@
//! Extensible, graph-based program representation with first-class support for linear types.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a copy paste of the lib docs? another thing to go out of date potentially?

@aborgna-q aborgna-q requested a review from ss2165 May 28, 2024 12:56
Copy link
Member

@ss2165 ss2165 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// proptest-derive generates many of these warnings.
// https://github.com/rust-lang/rust/issues/120363
// https://github.com/proptest-rs/proptest/issues/447
#![cfg_attr(test, allow(non_local_definitions))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't needed any more?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only needed in -core, where we define the proptests

@aborgna-q aborgna-q added this pull request to the merge queue May 28, 2024
Merged via the queue into main with commit bb1565f May 28, 2024
13 of 16 checks passed
@aborgna-q aborgna-q deleted the ab/hugr-core branch May 28, 2024 13:30
This was referenced May 23, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 29, 2024
## 🤖 New release
* `hugr`: 0.4.0 -> 0.5.0
* `hugr-cli`: 0.1.0
* `hugr-core`: 0.1.0
* `hugr-passes`: 0.1.0

<details><summary><i><b>Changelog</b></i></summary><p>

## `hugr`
<blockquote>

## 0.5.0 (2024-05-29)

### Bug Fixes

- Missing re-exports in `hugr::hugr`
([#1127](#1127))
- Set initial version of hugr-core to 0.1.0
([#1129](#1129))

### Features

- [**breaking**] Remove `PartialEq` impl for `ConstF64`
([#1079](#1079))
- [**breaking**] Allow "Row Variables" declared as List<Type>
([#804](#804))
- Hugr binary cli tool ([#1096](#1096))
- [**breaking**] Move passes from `algorithms` into a separate crate
([#1100](#1100))
- [**breaking**] Disallow nonlocal value edges into FuncDefn's
([#1061](#1061))
- [**breaking**] Move cli in to hugr-cli sub-crate
([#1107](#1107))
- Add verbosity, return `Hugr` from `run`.
([#1116](#1116))
- Unseal and make public the traits `HugrInternals` and
`HugrMutInternals` ([#1122](#1122))

### Refactor

- [**breaking**] No Ports in TypeRow
([#1087](#1087))
- Add a `hugr-core` crate
([#1108](#1108))
</blockquote>

## `hugr-core`
<blockquote>

## 0.1.0 (2024-05-29)

### Bug Fixes

- Set initial version of hugr-core to 0.1.0
([#1129](#1129))

### Features

- [**breaking**] Move cli in to hugr-cli sub-crate
([#1107](#1107))
- Make internals of int ops and the "int" CustomType more public.
([#1114](#1114))
- Unseal and make public the traits `HugrInternals` and
`HugrMutInternals` ([#1122](#1122))

### Refactor

- Add a `hugr-core` crate
([#1108](#1108))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

---------

Co-authored-by: Agustin Borgna <[email protected]>
@hugrbot hugrbot mentioned this pull request May 30, 2024
This was referenced Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hugr-internals crate
2 participants