Skip to content

Commit 849d950

Browse files
committed
comments and changelog
1 parent 01132d3 commit 849d950

File tree

4 files changed

+59
-24
lines changed

4 files changed

+59
-24
lines changed

CHANGELOG.md

+20-18
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
- Use FORCE_COLOR environmental variable to force colorized output https://github.com/rescript-lang/rescript-compiler/pull/7033
2222
- Allow spreads of variants in patterns (`| ...someVariant as v => `) when the variant spread is a subtype of the variant matched on. https://github.com/rescript-lang/rescript-compiler/pull/6721
23-
- Fix the issue where dynamic imports are not working for function-defined externals. https://github.com/rescript-lang/rescript-compiler/pull/7060
23+
- Fix the issue where dynamic imports are not working for function-defined externals. https://github.com/rescript-lang/rescript-compiler/pull/7060
24+
- Allow pattern matching on dicts. `switch someDict { | dict{"one": 1} => Js.log("one is one") }` https://github.com/rescript-lang/rescript-compiler/pull/7059
2425

2526
#### :bug: Bug fix
2627

@@ -316,7 +317,7 @@
316317

317318
#### :rocket: New Feature
318319

319-
- Experimental support of tagged template literals, e.g. ```sql`select * from ${table}```. https://github.com/rescript-lang/rescript-compiler/pull/6250
320+
- Experimental support of tagged template literals, e.g. `` sql`select * from ${table} ``. https://github.com/rescript-lang/rescript-compiler/pull/6250
320321
- Experimental support for generic/custom JSX transforms. https://github.com/rescript-lang/rescript-compiler/pull/6565
321322
- `dict` is now a builtin type. https://github.com/rescript-lang/rescript-compiler/pull/6590
322323

@@ -496,7 +497,7 @@ No changes compared to rc.9.
496497

497498
#### :boom: Breaking Change
498499

499-
- Stop mangling object field names. If you had objects with field names containing "__" or leading "_", they won't be mangled in the compiled JavaScript and represented as it is without changes. https://github.com/rescript-lang/rescript-compiler/pull/6354
500+
- Stop mangling object field names. If you had objects with field names containing "\__" or leading "_", they won't be mangled in the compiled JavaScript and represented as it is without changes. https://github.com/rescript-lang/rescript-compiler/pull/6354
500501

501502
#### :bug: Bug Fix
502503

@@ -551,7 +552,7 @@ No changes compared to rc.9.
551552

552553
#### :rocket: New Feature
553554

554-
- Introduced a new `%ffi` extension (*experimental* - not for production use!) that provides a more robust mechanism for JavaScript function interoperation by considering function arity in type constraints. This enhancement improves safety when dealing with JavaScript functions by enforcing type constraints based on the arity of the function. https://github.com/rescript-lang/rescript-compiler/pull/6251
555+
- Introduced a new `%ffi` extension (_experimental_ - not for production use!) that provides a more robust mechanism for JavaScript function interoperation by considering function arity in type constraints. This enhancement improves safety when dealing with JavaScript functions by enforcing type constraints based on the arity of the function. https://github.com/rescript-lang/rescript-compiler/pull/6251
555556
- Extended untagged variants with function types. https://github.com/rescript-lang/rescript-compiler/pull/6279
556557

557558
#### :boom: Breaking Change
@@ -629,14 +630,14 @@ No changes compared to rc.9.
629630

630631
#### :bug: Bug Fix
631632

632-
- Fix broken formatting in uncurried mode for functions with _ placeholder args. https://github.com/rescript-lang/rescript-compiler/pull/6148
633+
- Fix broken formatting in uncurried mode for functions with \_ placeholder args. https://github.com/rescript-lang/rescript-compiler/pull/6148
633634
- Fix issue where spreading record types with optional labels would not have their labels preserved as optional. https://github.com/rescript-lang/rescript-compiler/pull/6154
634635
- Fix error location to be the type with the spreads when spreading record types with duplicate labels. https://github.com/rescript-lang/rescript-compiler/pull/6157
635636
- Disable warning on `@inline` attibute on uncurried functions. https://github.com/rescript-lang/rescript-compiler/pull/6152
636637
- Support doc comments on arguments of function types. https://github.com/rescript-lang/rescript-compiler/pull/6161
637638
- Fix issue with record type coercion and unboxed. https://github.com/rescript-lang/rescript-compiler/issues/6158
638639
- Fixed subtype checking for record types with "@as" attributes: The subtype relationship now takes into account the compatibility of "@as" attributes between corresponding fields, ensuring correctness in runtime representation.
639-
https://github.com/rescript-lang/rescript-compiler/issues/6158
640+
https://github.com/rescript-lang/rescript-compiler/issues/6158
640641
- Emit directive above header comment. https://github.com/rescript-lang/rescript-compiler/pull/6172
641642
- Add error message to private extension. https://github.com/rescript-lang/rescript-compiler/pull/6175
642643

@@ -665,7 +666,6 @@ No changes compared to rc.9.
665666

666667
- Special case generation of uncurried functions with 1 argument of unit type so they don't take a parameter. https://github.com/rescript-lang/rescript-compiler/pull/6131
667668

668-
669669
# 11.0.0-alpha.1
670670

671671
#### :rocket: Main New Feature
@@ -676,16 +676,16 @@ No changes compared to rc.9.
676676
#### :rocket: New Feature
677677

678678
- Add support for uncurried mode: a mode where everything is considered uncurried, whether with or without the `.`. This can be turned on with `@@uncurried` locally in a file. For project-level configuration in `bsconfig.json`, there's a boolean config `"uncurried"`, which propagates to dependencies, to turn on uncurried mode.
679-
Since there's no syntax for partial application in this new mode, introduce `@res.partial foo(x)` to express partial application. This is temporary and will later have some surface syntax.
680-
Make uncurried functions a subtype of curried functions, and allow application for uncurried functions.
681-
The `make` function of components is generated as an uncurried function.
682-
Use best effort to determine the config when formatting a file.
683-
https://github.com/rescript-lang/rescript-compiler/pull/5968 https://github.com/rescript-lang/rescript-compiler/pull/6080 https://github.com/rescript-lang/rescript-compiler/pull/6086 https://github.com/rescript-lang/rescript-compiler/pull/6087
679+
Since there's no syntax for partial application in this new mode, introduce `@res.partial foo(x)` to express partial application. This is temporary and will later have some surface syntax.
680+
Make uncurried functions a subtype of curried functions, and allow application for uncurried functions.
681+
The `make` function of components is generated as an uncurried function.
682+
Use best effort to determine the config when formatting a file.
683+
https://github.com/rescript-lang/rescript-compiler/pull/5968 https://github.com/rescript-lang/rescript-compiler/pull/6080 https://github.com/rescript-lang/rescript-compiler/pull/6086 https://github.com/rescript-lang/rescript-compiler/pull/6087
684684
- Customization of runtime representation of variants. This is work in progress. E.g. some restrictions on the input. See comments of the form "TODO: put restriction on the variant definitions allowed, to make sure this never happens". https://github.com/rescript-lang/rescript-compiler/pull/6095
685685
- Introduce untagged variants https://github.com/rescript-lang/rescript-compiler/pull/6103
686686
- Add support for unary uncurried pipe in uncurried mode https://github.com/rescript-lang/rescript-compiler/pull/5804
687687
- Add support for partial application of uncurried functions: with uncurried application one can provide a
688-
subset of the arguments, and return a curried type with the remaining ones https://github.com/rescript-lang/rescript-compiler/pull/5805
688+
subset of the arguments, and return a curried type with the remaining ones https://github.com/rescript-lang/rescript-compiler/pull/5805
689689
- Add support for uncurried externals https://github.com/rescript-lang/rescript-compiler/pull/5815 https://github.com/rescript-lang/rescript-compiler/pull/5819 https://github.com/rescript-lang/rescript-compiler/pull/5830 https://github.com/rescript-lang/rescript-compiler/pull/5894
690690
- Parser/Printer: unify uncurried functions of arity 0, and of arity 1 taking unit. There's now only arity 1 in the source language. https://github.com/rescript-lang/rescript-compiler/pull/5825
691691
- Add support for default arguments in uncurried functions https://github.com/rescript-lang/rescript-compiler/pull/5835
@@ -707,12 +707,12 @@ subset of the arguments, and return a curried type with the remaining ones https
707707
- `rescript convert <reason files>`
708708
- Remove obsolete built-in project templates and the "rescript init" functionality. This is replaced by [create-rescript-app](https://github.com/rescript-lang/create-rescript-app) which is maintained separately.
709709
- Do not attempt to build ReScript from source on npm postinstall for platforms without prebuilt binaries anymore.
710-
- Made pinned dependencies transitive: if *a* is a pinned dependency of *b* and *b* is a pinned dependency of *c*, then *a* is implicitly a pinned dependency of *c*. This change is only breaking if your build process assumes non-transitivity.
710+
- Made pinned dependencies transitive: if _a_ is a pinned dependency of _b_ and _b_ is a pinned dependency of _c_, then _a_ is implicitly a pinned dependency of _c_. This change is only breaking if your build process assumes non-transitivity.
711711
- Curried after uncurried is not fused anymore: `(. x) => y => 3` is not equivalent to `(. x, y) => 3` anymore. It's instead equivalent to `(. x) => { y => 3 }`.
712-
Also, `(. int) => string => bool` is not equivalen to `(. int, string) => bool` anymore.
713-
These are only breaking changes for unformatted code.
712+
Also, `(. int) => string => bool` is not equivalen to `(. int, string) => bool` anymore.
713+
These are only breaking changes for unformatted code.
714714
- Exponentiation operator `**` is now right-associative. `2. ** 3. ** 2.` now compile to `Math.pow(2, Math.pow(3, 2))` and not anymore `Math.pow(Math.pow(2, 3), 2)`. Parentheses can be used to change precedence.
715-
- Remove unsafe ``` j`$(a)$(b)` ``` interpolation deprecated in compiler version 10 https://github.com/rescript-lang/rescript-compiler/pull/6068
715+
- Remove unsafe `` j`$(a)$(b)` `` interpolation deprecated in compiler version 10 https://github.com/rescript-lang/rescript-compiler/pull/6068
716716
- Remove deprecated module `Printexc`
717717
- `@deriving(jsConverter)` not supported anymore for variant types https://github.com/rescript-lang/rescript-compiler/pull/6088
718718
- New representation for variants, where the tag is a string instead of a number. https://github.com/rescript-lang/rescript-compiler/pull/6088
@@ -761,19 +761,21 @@ These are only breaking changes for unformatted code.
761761
# 10.1.4
762762

763763
#### :bug: Bug Fix
764+
764765
- Fix implementation of directives https://github.com/rescript-lang/rescript-compiler/pull/6052
765766
- Fix issue if the `lib` dir is included in the sources of bsconfig.json https://github.com/rescript-lang/rescript-compiler/pull/6055
766767
- Fix issue with string escape in pattern match https://github.com/rescript-lang/rescript-compiler/pull/6062
767768
- Fix issue with literal comparison of string constants https://github.com/rescript-lang/rescript-compiler/pull/6065
768769

769770
#### :rocket: New Feature
771+
770772
- Add support for toplevel `await` https://github.com/rescript-lang/rescript-compiler/pull/6054
771773

772774
#### :nail_care: Polish
773775

774776
- Better error message for extension point https://github.com/rescript-lang/rescript-compiler/pull/6057
775777
- Improve format check help https://github.com/rescript-lang/rescript-compiler/pull/6056
776-
- Deprecate unsafe ``` j`$(a)$(b)` ``` interpolation: use string templates ``` `${a}${b}` ``` instead https://github.com/rescript-lang/rescript-compiler/pull/6067
778+
- Deprecate unsafe `` j`$(a)$(b)` `` interpolation: use string templates `` `${a}${b}` `` instead https://github.com/rescript-lang/rescript-compiler/pull/6067
777779

778780
# 10.1.3
779781

jscomp/ml/dict_type_helpers.ml

+30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
(*
2+
An overview of the implementation of dicts in ReScript:
3+
### What is a dict?
4+
Dicts are effectively an object with unknown fields, but a single known type of the values it holds.
5+
6+
### How are they implemented?
7+
Dicts in ReScript are implemented as predefined record type, with a single (magic) field that holds
8+
the type of the dict's values. This field is called `dictValuesType`, and is just an implementation
9+
detail - it's never actually exposed to the user, just used internally.
10+
11+
The compiler will route any label lookup on the dict record type to the magic field, which creates a
12+
record with unknown keys, but of a single type.
13+
14+
The reason for this seemingly convoluted implementation is that it allows us to piggyback on the
15+
existing record pattern matching mechanism, which means we get pattern matching on dicts for free.
16+
17+
### Modifications to the type checker
18+
We've made a few smaller modifications to the type checker to support this implementation:
19+
20+
- We've added a new predefined type `dict` that is a record with a single field called `dictValuesType`.
21+
This type is used to represent the type of the values in a dict.
22+
- We've modified the type checker to recognize `dict` patterns, and route them to the predefined `dict` type.
23+
This allows us to get full inference for dicts in patterns.
24+
25+
### Syntax
26+
There's first class syntax support for dicts, both as expressions and as patterns.
27+
A dict pattern is treated as a record pattern in the compiler and syntax, with an attriubute `@res.dictPattern`
28+
attached to it. This attribute is used to tell the compiler that the pattern is a dict pattern, and is what
29+
triggers the compiler to treat the dict record type differently to regular record types.
30+
*)
131
let dict_magic_field_name = "dictValuesType"
232

333
let has_dict_pattern_attribute attrs =

jscomp/ml/predef.ml

+8-5
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,14 @@ let common_initial_env add_type add_extension empty_env =
220220
type_variance = [Variance.covariant; Variance.covariant]}
221221
and decl_dict =
222222
let tvar = newgenvar() in
223-
(* Dicts are implented as a as a single "magic" field record. This magic field
224-
is then leveraged to be able to piggy back on the existing record pattern
225-
matching mechanism. So, this definition is import for the dict pattern
226-
matching functionality, but not something intended to be exposed to the
227-
user. *)
223+
(* Dicts are implemented as a single "magic" field record. This magic field
224+
is the medium through which we can piggy back on the existing record pattern
225+
matching mechanism. We do this by letting the compiler route any label lookup
226+
for the dict record type to the magic field, which has the type of the values
227+
of the dict.
228+
229+
So, this definition is important for the dict pattern matching functionality,
230+
but not something intended to be exposed to the user. *)
228231
{decl_abstr with
229232
type_attributes = [Dict_type_helpers.dict_attr];
230233
type_params = [tvar];

jscomp/ml/typecore.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ end) = struct
806806
Env.mark_type_used env (Path.last tpath) (Env.find_type tpath env);
807807
let is_dict = Path.same tpath Predef.path_dict in
808808
if is_dict then (
809-
(* [dict] Dicts are implented as a record with a single "magic" field. This magic field is
809+
(* [dict] Dicts are implemented as a record with a single "magic" field. This magic field is
810810
used to track the dict value type, and any label lookup on the dict record type
811811
will give that single value type back. This is how we can piggy back on the record
812812
pattern matching mechanism.

0 commit comments

Comments
 (0)