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

Move to a module based configuration #214

Merged
merged 27 commits into from
Jun 4, 2024

Conversation

n-osborne
Copy link
Collaborator

@n-osborne n-osborne commented Mar 28, 2024

Fixes #173

This PR proposes to move from a command-line based configuration to a module-based configuration.

It does so adopting the proposition of this comment

It is in two folds: the first 17 commits change the way Ortac/QCheck-STM is configured and the next 4 commits update the Ortac/Dune plugin and the examples.

The changes in the Ortac/Dune module also integrate some sort of fix: the ortac dune qcheck-stm command now takes the actual filenames (that is with the extensions). I find it to be more natural.

@n-osborne n-osborne force-pushed the module-based-config branch 3 times, most recently from dd380c5 to a927718 Compare March 28, 2024 17:36
@n-osborne n-osborne force-pushed the module-based-config branch from a927718 to 4aa0084 Compare April 10, 2024 12:56
@n-osborne n-osborne modified the milestones: 0.2, 0.3 Apr 11, 2024
@n-osborne n-osborne force-pushed the module-based-config branch 5 times, most recently from 4ef4a96 to 662cdde Compare April 17, 2024 12:49
@shym shym self-requested a review May 6, 2024 13:44
@n-osborne n-osborne force-pushed the module-based-config branch from 662cdde to 27ae30d Compare May 16, 2024 09:57
Copy link
Contributor

@shym shym left a comment

Choose a reason for hiding this comment

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

This is really nice work, well done!

  • Would it make sense to detect whether part of the configuration is useless / unused, to help users figure out that something they think they have configured is not properly interpreted as such?
    A related issue (also pointed out somewhere in index.mld but worth a more general note): it would be nice for the configuration module to be as OCaml-code as possible, so that OCaml and Merlin could help write sound configurations. I think we are mostly there already, it would maybe mean not breaking that property when detecting what is skipped, making sure that the example configurations are actually valid OCaml code and tell something about them to dune so that they are typechecked.

  • ba6dd9d Change command-line interface for a module-base config
    reorders entries in Reserr so that there are in a canonical order. That change is most welcome but:

    • could it be split in a specific commit, it is worth a change on its own,
    • could it be generalised, to all types and both to .ml and .mli?
  • Could init_sut_txt be set up to the original source code? If it is always generated from init_sut, I would rather keep only that in the data structures, as a very simple way to ensure we have no inconsistency and so the comment at line 45 in Config could be skipped.

  • 1b105e5 Collect optional content for the Gen module
    I could do with some comment to explain what this module is meant to contain

  • b3c82da Add tests for inclusion of ty extensions
    I expected to see ty extensions in the tests (shouldn’t there be a Ty module in the configuration for that?)

  • 27ae30d Update Changelog
    Even when old features get removed, they shouldn’t disappear from the changelog, especially from a past version. Your new changelog entry might say that some past features are removed on the way, if need be.

| _ ->
let str = Fmt.str "%a" Ppxlib_ast.Pprintast.core_type core_type in
error (Sut_type_not_supported str, Location.none)

let sut_core_type str =
let value_bindings cfg_uc =
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename it extract_init_sut or something similar? (If I read it correctly, the current name is a duplicate of the type signature)

let open Ppxlib in
try Parse.expression (Lexing.from_string str) |> Reserr.ok
with _ -> Reserr.(error (Syntax_error_in_init_sut str, Location.none))
let type_declarations cfg_uc =
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename it extract sut or something similar?

in
fold_left aux cfg_uc

let module_binding cfg_uc (mb : Ppxlib.module_binding) =
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename it extract gen_module or something similar?

@n-osborne n-osborne force-pushed the module-based-config branch from 27ae30d to ada2afc Compare May 23, 2024 15:37
@n-osborne
Copy link
Collaborator Author

Thanks for the review:

The typos should be fixed.

I've splited and reordered commits regarding sorting, removing and adding constructors for reserr errors.

Regarding the use of init_sut_txt, I've removed it from the config under construction but kept it in the actual config. It was added in c6b13f6 and I believe removing it here would make a bit too much noise. But I keep it in mind for the future.

Regarding renaming, you read correctly, I gave functions the name of the node of the OCaml AST they are inspecting, not making any assumption on the information they collect. In a future PR (I know, I'm thinking backward in time here...) the value_bindings function will also collect the optional cleanup configuration. Maybe some documentation could be enough?

On the importance of testing: I indeed misplaced the STM.ty extension in the testing configuration. Well spotted! Now that it is in the right place, OCaml compiler doesn't accept the generated code! I have to investigate that a bit more.

@shym
Copy link
Contributor

shym commented May 24, 2024

Regarding renaming […] Maybe some documentation could be enough?

Yes, some documentation to explain what the functions extract would be fine too.

On the importance of testing: I indeed misplaced the STM.ty extension in the testing configuration. Well spotted! Now that it is in the right place, OCaml compiler doesn't accept the generated code! I have to investigate that a bit more.

😅

Will need it shortly.
@n-osborne n-osborne force-pushed the module-based-config branch 3 times, most recently from 6a0fd19 to 7517797 Compare May 27, 2024 12:36
@n-osborne n-osborne force-pushed the module-based-config branch from 7517797 to b25504b Compare May 28, 2024 14:05
Copy link
Contributor

@shym shym left a comment

Choose a reason for hiding this comment

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

I’ve reviewed mostly the range-diff, it looks good, thank you!
Could I be so bold as to suggest for Reorder warnings… to also reorder pp_kind, for uniformity?


{ul {li custom [QCheck] generators in a [Gen] module}
{li custom [STM] printers in a [Pp] module}
{li custom [STM.ty] extensions and its functional construtors in a [Ty]
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: constructors

@n-osborne n-osborne force-pushed the module-based-config branch 2 times, most recently from 23acab5 to c8d8d78 Compare June 4, 2024 09:29
@n-osborne
Copy link
Collaborator Author

Thanks.
Reordering pp_kind is indeed a good idea. Though there is a bit too much rebase work that it is worth to include the reordering to the Reordering warnings... commit, I add one near the end of the PR.

Waiting for the CI to be green again then merging.

@n-osborne n-osborne force-pushed the module-based-config branch from c8d8d78 to ae6f8fe Compare June 4, 2024 09:45
@shym
Copy link
Contributor

shym commented Jun 4, 2024

Just need reformatting.

@n-osborne n-osborne force-pushed the module-based-config branch from ae6f8fe to e190f82 Compare June 4, 2024 10:47
@n-osborne n-osborne merged commit 3f21940 into ocaml-gospel:main Jun 4, 2024
3 checks passed
@n-osborne n-osborne deleted the module-based-config branch June 4, 2024 11:13
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.

Add/Move to a module-based configuration
2 participants