Skip to content

Conversation

erikmd
Copy link
Collaborator

@erikmd erikmd commented Nov 6, 2021

Description

  • Add option learn-ocaml build --enable-cmo-build
  • This new experimental option is on by default (implicit mode) and generates given_exo.{cmi,cmo,cmt} in the www folder for each prelude ^ " ;;\n" ^ prepare.
  • This is a key feature for learn-ocaml.el (the Tuareg/Merlin frontend for Learn-OCaml); it can be disabled using the flag:
    $ learn-ocaml build --disable-cmo-build
    
  • If the www/exo.json file is up-to-date, the exo.cm* are not built.
  • But we can force the exo.cm* build (explicit mode) even for un-changed exercises using the flag:
    $ learn-ocaml build --enable-cmo-build
    
  • This option may later become mandatory if/when the js_of_ocaml front-end also fetches similar *.cmo files.
  • Regarding the ocamlc naming convention:
    require that the input exercise id basename exo-name matches [0-9A-Za-z_-]+, otherwise raise a warning,
    then bijectively replace __0 and -_1 in exo, then yield the output filename dir/given_exo_1name.cmo.

Checklist

  • Read the CONTRIBUTING.md guide.
  • Add/update tests
  • Implement the learn-ocaml-client counterpart of this feature within this PR

Note to maintainers

  • Read this wiki page
  • Make sure the PR has a milestone
  • Assign yourself before merging (using a regular Merge for this one)

@erikmd erikmd added the kind: feature New user-facing feature. label Nov 6, 2021
@erikmd erikmd added this to the learn-ocaml 0.14.0 milestone Nov 6, 2021
erikmd added a commit to pfitaxel/learn-ocaml that referenced this pull request Nov 7, 2021
Spotted with (docker, `learn-ocaml build --enable-cmo-build`) from PR ocaml-sf#458:
```
LOGS:
Learnocaml v.0.14.0 running.
Updating app at ./www
given_int_0exo           (build .cmo)
Cannot process exercises: Env.Error(_)
```
Note: this latter exception backtrace could be improved (giving more details).

Close ocaml-sf#438
erikmd added a commit to pfitaxel/learn-ocaml-corpus that referenced this pull request Nov 7, 2021
MOTIVATION:

After ocaml-sf/learn-ocaml#458,
we'll precompile {prelude,prepare}.ml in `*.cm*` files.

The previous implementation led to a compilation issue:

```
File "prepare.ml", line 7, characters 4-7:
7 | let (!), get_count =
        ^^^
Error: The type of this expression, '_weak1 ref -> '_weak1,
       contains type variables that cannot be generalized
```
erikmd added a commit to pfitaxel/learn-ocaml-corpus that referenced this pull request Nov 7, 2021
MOTIVATION:

After ocaml-sf/learn-ocaml#458,
we'll precompile {prelude,prepare}.ml in `*.cm*` files.

The previous implementation led to a compilation issue:

```
File "prepare.ml", line 7, characters 4-7:
7 | let (!), get_count =
        ^^^
Error: The type of this expression, '_weak1 ref -> '_weak1,
       contains type variables that cannot be generalized
```
erikmd added a commit to ocaml-sf/learn-ocaml-corpus that referenced this pull request Nov 7, 2021
MOTIVATION:

After ocaml-sf/learn-ocaml#458,
we'll precompile {prelude,prepare}.ml in `*.cm*` files.

The previous implementation led to a compilation issue:

```
File "prepare.ml", line 7, characters 4-7:
7 | let (!), get_count =
        ^^^
Error: The type of this expression, '_weak1 ref -> '_weak1,
       contains type variables that cannot be generalized
```
@erikmd erikmd force-pushed the generate-cmo branch 2 times, most recently from 7dd6385 to a05bf78 Compare November 8, 2021 17:45
@erikmd erikmd marked this pull request as draft January 3, 2022 08:08
* This new experimental option is on by default (implicit mode)
  and generates `given_exo.{cmi,cmo,cmt}` in the www folder for each
  `prelude ^ " ;;\n" ^ prepare`.

* This is a key feature for learn-ocaml.el (the Tuareg/Merlin frontend
  for Learn-OCaml, https://github.com/pfitaxel/learn-ocaml.el );
  it can be disabled using the flag:
  $ learn-ocaml build --disable-cmo-build

* If the www/exo.json file is up-to-date, the `exo.cm*` are not built.

* But we can force the `exo.cm*` build (explicit mode) using the flag:
  $ learn-ocaml build --enable-cmo-build

* This option may later become mandatory if/when the js_of_ocaml front
  also fetches similar `*.cmo` files.
@yurug
Copy link
Collaborator

yurug commented Jan 27, 2023

Closed subsumed by #481.

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

Labels

kind: feature New user-facing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants