Skip to content

Commit 6890386

Browse files
maisteart-w
andcommitted
chore(review): apply @art-w review
Co-authored-by: art-w <[email protected]> Signed-off-by: Etienne Marais <[email protected]>
1 parent 4c59678 commit 6890386

File tree

6 files changed

+25
-26
lines changed

6 files changed

+25
-26
lines changed

doc/reference/dune/library_parameter.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ library_parameter
66
This feature is experimental and requires the compiler you are using to
77
support parameterized libraries.
88

9-
The ``library_parameter`` describes a parameter. To be able to use the feature,
10-
you need to enable the stanza using the ``(using oxcaml 0.1)`` :doc:`extension
9+
The ``library_parameter`` stanza describes a parameter interface defined in a single ``.mli`` file. To enable this feature,
10+
you need to add ``(using oxcaml 0.1)`` :doc:`extension
1111
</reference/dune-project/using>` in your ``dune-project`` file.
1212

1313
.. describe:: (library_parameter ...)
@@ -18,7 +18,7 @@ you need to enable the stanza using the ``(using oxcaml 0.1)`` :doc:`extension
1818

1919
.. describe:: (name <parameter-name>)
2020

21-
``parameter-name`` is the real of the library parameter. It must be a valid
21+
``parameter-name`` is the name of the library parameter. It must be a valid
2222
OCaml module name as for :doc:`/reference/dune/library`.
2323

2424
This must be specified if no `public_name` is specified.
@@ -44,10 +44,7 @@ you need to enable the stanza using the ``(using oxcaml 0.1)`` :doc:`extension
4444

4545
.. describe:: (modules <modules>)
4646

47-
Specifies what modules are part of the library parameter. By default, Dune will use
48-
all the ``.mli`` files in the same directory as the ``dune`` file. This
49-
includes ones present in the file system as well as ones generated by user
50-
rules. You can restrict this list by using a ``(modules <modules>)`` field.
47+
Specifies a specific module to select as a `library_parameter`.
5148

5249
``<modules>`` uses the :doc:`/reference/ordered-set-language`, where
5350
elements are module names and don't need to start with an uppercase letter.
@@ -97,9 +94,9 @@ you need to enable the stanza using the ``(using oxcaml 0.1)`` :doc:`extension
9794

9895
.. describe:: (enabled_if <blang expression>)
9996

100-
Conditionally disables a library.
97+
Conditionally disables a library parameter.
10198

102-
A disabled library cannot be built and will not be installed.
99+
A disabled library parameter cannot be built and will not be installed.
103100

104101
The condition is specified using the :doc:`/reference/boolean-language`, and
105102
the field allows for the ``%{os_type}`` variable, which is expanded to the

src/dune_rules/gen_meta.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ let gen_lib pub_name lib ~version =
7676
in
7777
let preds =
7878
match kind with
79-
| Normal -> []
80-
| Parameter -> [] (* failwith "TODO arthur" *)
79+
| Normal | Parameter -> []
8180
| Ppx_rewriter _ | Ppx_deriver _ -> [ Pos "ppx_driver" ]
8281
in
8382
let name lib =
@@ -128,8 +127,7 @@ let gen_lib pub_name lib ~version =
128127
; ppx_runtime_deps ppx_rt_deps
129128
])
130129
; (match kind with
131-
| Normal -> []
132-
| Parameter -> [] (* failwith "TODO arthur" *)
130+
| Normal | Parameter -> []
133131
| Ppx_rewriter _ | Ppx_deriver _ ->
134132
(* Deprecated ppx method support *)
135133
let no_ppx_driver = Neg "ppx_driver"
@@ -141,8 +139,7 @@ let gen_lib pub_name lib ~version =
141139
; requires ~preds:[ no_ppx_driver ] ppx_runtime_deps_for_deprecated_method
142140
]
143141
; (match kind with
144-
| Normal -> assert false
145-
| Parameter -> assert false (* failwith "TODO arthur" *)
142+
| Normal | Parameter -> assert false
146143
| Ppx_rewriter _ ->
147144
[ rule "ppx" [ no_ppx_driver; no_custom_ppx ] Set "./ppx.exe --as-ppx"
148145
; rule "library_kind" [] Set "ppx_rewriter"

src/dune_rules/modules_field_evaluator.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ let eval
389389
if Module_trie.mem private_modules name then Visibility.Private else Public
390390
in
391391
let kind =
392-
if kind = Parameter
392+
if is_parameter
393393
then Module.Kind.Parameter
394394
else if Module_trie.mem virtual_modules name
395395
then Virtual

src/dune_rules/stanzas/parameter.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ let decode =
7777
; allow_overlapping_dependencies
7878
; ctypes = None
7979
}
80-
(* let+ buildable = Buildable.decode Parameter *)
8180
and+ name = field_o "name" Lib_name.Local.decode_loc
8281
and+ public = field_o "public_name" (Public_lib.decode ~allow_deprecated_names:false)
8382
and+ package = field_o "package" (located Stanza_common.Pkg.decode)
84-
and+ enabled_if = Enabled_if.decode ~allowed_vars:Any ~since:(Some (3, 20)) ()
83+
and+ enabled_if = Enabled_if.decode ~allowed_vars:Any ~since:None ()
8584
and+ synopsis = field_o "synopsis" string
8685
and+ stdlib =
8786
field_o
@@ -97,11 +96,11 @@ let decode =
9796
| Error user_message ->
9897
User_error.raise
9998
~loc
100-
[ Pp.textf "Invalid library name."
99+
[ Pp.textf "Invalid library_parameter name."
101100
; Pp.text
102-
"Public library names don't have this restriction. You can either \
103-
change this public name to be a valid library name or add a \"name\" \
104-
field with a valid library name."
101+
"Public library_parameter names don't have this restriction. You can \
102+
either change this public name to be a valid library_parameter name \
103+
or add a \"name\" field with a valid library_parameter name."
105104
]
106105
~hints:(Lib_name.Local.valid_format_doc :: user_message.hints))
107106
| None, None ->

src/dune_rules/utop.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ let add_stanza db ~dir (acc, pps) stanza =
5757
then (
5858
match Lib_info.kind info with
5959
| Normal -> Appendable_list.cons lib acc, pps
60-
| Parameter -> failwith "TODO arthur"
60+
| Parameter -> Appendable_list.cons lib acc, pps
61+
(* CR @maiste or @art-w: the parametrized libraries in utop follows
62+
the same schema as Normal library but it needs to be verified once
63+
parametrized libraries are fully supported. *)
6164
| Lib_kind.Ppx_rewriter _ | Ppx_deriver _ ->
6265
( Appendable_list.cons lib acc
6366
, Appendable_list.cons (Lib_info.loc info, Lib_info.name info) pps ))
@@ -96,7 +99,10 @@ let add_stanza db ~dir (acc, pps) stanza =
9699
let info = Lib.info lib in
97100
match Lib_info.kind info with
98101
| Normal -> Appendable_list.cons lib acc, pps
99-
| Parameter -> failwith "TODO arthur"
102+
| Parameter -> Appendable_list.cons lib acc, pps
103+
(* CR @maiste or @art-w: the parametrized libraries in utop follows
104+
the same schema as Normal library but it needs to be verified once
105+
parametrized libraries are fully supported. *)
100106
| Ppx_rewriter _ | Ppx_deriver _ ->
101107
( Appendable_list.cons lib acc
102108
, Appendable_list.cons (Lib_info.loc info, Lib_info.name info) pps )))

test/blackbox-tests/test-cases/oxcaml/library_parameter.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This test verifies `library_parameter` stanza works as expected.
1+
This test verifies that the `library_parameter` stanza works as expected.
22

33
$ . ./helpers.sh
44
$ cat > "dune-project" <<EOF
@@ -18,7 +18,7 @@ being lazy.
1818
> (name param_intf))
1919
> EOF
2020

21-
The test build should fails because of the oxcaml extension is not available.
21+
The test build should fails because the oxcaml extension is not available.
2222

2323
$ dune build
2424
File "param/dune", lines 1-3, characters 0-64:

0 commit comments

Comments
 (0)