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

with-kinds #3284

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8814e2c
Use estimate_type_jkind instead of type_jkind_purely
goldfirere Dec 3, 2024
53b02d3
Skip reporting errors in extra with-type jkind check
goldfirere Nov 29, 2024
0666ec8
Use in_subst for omitting the jkind check in subst
goldfirere Nov 29, 2024
3274c88
Add a necessary "instance".
goldfirere Nov 26, 2024
4ab1075
Remove unused equal function
goldfirere Nov 12, 2024
8c85229
Add with-kinds.
goldfirere Nov 13, 2024
6770037
Adapt to unboxed records
goldfirere Dec 13, 2024
2593656
Update test output
goldfirere Dec 16, 2024
c0a9d50
Add tests
liam923 Dec 17, 2024
f498428
Reviewed the tests, with minor revisions
goldfirere Dec 19, 2024
57387ff
Commit failing test
goldfirere Dec 20, 2024
a20a171
Use better hygeine around univar_pairs
goldfirere Dec 20, 2024
52da5d6
Failing test about re-exporting ref
goldfirere Dec 20, 2024
9765046
Don't add baggage to top
goldfirere Dec 20, 2024
25eadb9
Some final touches
goldfirere Dec 20, 2024
c03d79c
Use real type equality when checking decl jkinds
glittershark Dec 28, 2024
a219496
Liam's review
goldfirere Jan 9, 2025
5b86881
Zesen's doc improvements
goldfirere Jan 9, 2025
ad92250
Reshuffle Lattice into Axis_ops
goldfirere Jan 9, 2025
2fd600c
Improve comment (from Ryan)
goldfirere Jan 9, 2025
1f6e7bf
Suggestions from Ryan
goldfirere Jan 9, 2025
65f2e6b
Comments from Zesen
goldfirere Jan 9, 2025
59ff14b
Share impls for Monad.Basic and Monad.Basic2
liam923 Jan 10, 2025
4473fb8
Revert change 3274c88e, an unnecessary [instance]
goldfirere Jan 17, 2025
ce95b1f
Show that strange behavior is only printing
goldfirere Jan 17, 2025
5d07d15
Liam's comments
goldfirere Jan 17, 2025
d87cfbf
Change suggested by Zesen
goldfirere Jan 17, 2025
e032000
More Liam review
goldfirere Jan 17, 2025
5d7e485
Responses to Leo's comments
goldfirere Jan 20, 2025
0ca4ba4
Add test demonstrating issue
liam923 Jan 30, 2025
1835b5d
Add soundness bug
liam923 Jan 30, 2025
d1b324e
Round up in Tpoly
goldfirere Feb 5, 2025
94ce24a
Add a flag to control inference of with-bounds on type decls (#3547)
glittershark Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions jane/doc/extensions/uniqueness/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ type delayed_free = { id : int; callback : unit -> unit }
let get_id : delayed_free @ once -> int @ many = fun t -> t.id
```

We are working on a feature which will make it possible to use a value as `many`
if its type prevents it from containing a function. For example, you will then
be able to use an `int list @ once aliased` as `many` (but not as `unique`).
This mode-crossing works through container types. For example, you can use an
goldfirere marked this conversation as resolved.
Show resolved Hide resolved
`int list @ once aliased` as `many` (but not as `unique`).

## Checking for Uniqueness

Expand Down
8 changes: 4 additions & 4 deletions jane/doc/proposals/kind-inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ rec {
q ::= best | not_best (* quality of an inferred kind; best < not_best *)
```

Mode crossing is not covered in this design.
Mode crossing is not covered in this design.

However, it may be helpful to know that having e.g. `mod observing` in a kind
means that `observing` is the upper bound for the locality mode of values whose
Expand All @@ -158,14 +158,14 @@ that kind. Suppose `t : ... mod exclusive`. If a context requires `e` of type
`exclusive` is sufficient. A requirement of `aliased` (the top mode) is
completely unaffected.

The key question: if `t : ... mod exclusive` and we have
The key question: if `t : ... mod exclusive` and we have
`type ('a : ... mod aliased) t2`, is `t t2` valid? No! Even though
`exclusive < aliased`. That's because `mod aliased` puts a *harder* requirement
on its type (it must be agnostic between all of `unique`, `exclusive`, and
`aliased`) than `mod exclusive` does (which says the type is agnostic between
`unique` and `exclusive` only). This means that the subkind relation works
backwards on monadic axes: `... mod aliased ≤ ... mod exclusive`. For this
reason, in the presentation above, the monadic axis elements are listed in
reason, in the presentation above, the monadic axis elements are listed in
reverse order: this document does not care about submoding or mode crossing
directly, and writing the axes in reverse order gives us the right behavior
on subkinding.
Expand Down Expand Up @@ -256,7 +256,7 @@ rec {
Γ ⊢ jkind with field_types ↠ lay(χ); ⟪Ξ(χ) with types_for(Ξ, field_types)⟫
```

In `K_OF`, we produce a kind in terms of `τ`, not just `κ`. This allows us
In `KS_OF`, we produce a kind in terms of `τ`, not just `κ`. This allows us
to make use of refinements to `τ` that we learn later, perhaps through
functor application or GADT refinement.

Expand Down
4 changes: 2 additions & 2 deletions otherlibs/dynlink/dune
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Primitive.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Oprint.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Typemode.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Jkind.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Btype.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Jkind.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Subst.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Signature_with_global_bindings.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Bytesections.cmo
Expand Down Expand Up @@ -697,8 +697,8 @@
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Primitive.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Oprint.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Typemode.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Jkind.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Btype.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Jkind.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Subst.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Signature_with_global_bindings.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Bytesections.cmx
Expand Down
1 change: 1 addition & 0 deletions parsing/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -3964,6 +3964,7 @@ jkind_desc:
in
Mod ($1, modes)
}
(* CR layouts v2.8: The types should be separated by AND, not WITH *)
| jkind_annotation WITH core_type {
With ($1, $3)
}
Expand Down
2 changes: 2 additions & 0 deletions parsing/parsetree.mli
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,8 @@ and module_binding =
and jkind_annotation_desc =
| Default
| Abbreviation of string
(* CR layouts v2.8: [mod] can have only layouts on the left, not
full kind annotations. We may want to narrow this type some. *)
| Mod of jkind_annotation * modes
| With of jkind_annotation * core_type
| Kind_of of core_type
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/typing-immediate/immediate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ end;;
Line 2, characters 2-41:
2 | type t = Foo of int | Bar [@@immediate]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The kind of type "t" is value
Error: The kind of type "t" is immutable_data
because it's a boxed variant type.
But the kind of type "t" must be a subkind of immediate
because of the annotation on the declaration of the type t.
Expand All @@ -174,7 +174,7 @@ end;;
Line 2, characters 2-38:
2 | type t = { foo : int } [@@immediate]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The kind of type "t" is value
Error: The kind of type "t" is immutable_data
because it's a boxed record type.
But the kind of type "t" must be a subkind of immediate
because of the annotation on the declaration of the type t.
Expand Down
4 changes: 3 additions & 1 deletion testsuite/tests/typing-layouts-or-null/reexport.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Lines 2-4, characters 2-16:
4 | | This of 'a
Error: The kind of type "'a or_null" is value_or_null
because it is the primitive value_or_null type or_null.
But the kind of type "'a or_null" must be a subkind of value
But the kind of type "'a or_null" must be a subkind of
value mod local with 'a aliased with 'a many with 'a
uncontended with 'a portable with 'a internal with 'a
because of the definition of t at lines 2-4, characters 2-16.
|}]

Expand Down
Loading