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

Feature request: suppress/abbreviate module type output #452

Open
dlesbre opened this issue May 7, 2024 · 0 comments
Open

Feature request: suppress/abbreviate module type output #452

dlesbre opened this issue May 7, 2024 · 0 comments

Comments

@dlesbre
Copy link

dlesbre commented May 7, 2024

Maybe related to #282.

When defining module in an interactive session, OCaml tends to print the full expended signature:

# module M = Map.Make(Int);;
module M :
  sig
    (* Insert >50 lines here *)
  end

Having this in your readme or documentation is basically never desired behavior. Having a way to shorten it or use named modules would be nice:

  • option one: allow a abbreviated version (perhaps with a simple label to toggle on off).
    With this option, this should not generate any error:

    <!-- $MDX abbrev -->
    ```ocaml
    # module M = Map.Make(Int);;
    module M : sig ... end 
    ```
  • option two: allow subtyping (probably much harder to do).
    with this option this should also check that M can be given the supplied type

    <!-- $MDX module-subtypes -->
    ```ocaml
    # module M = Map.Make(Int);;
    module M <: Map.S with type key = int
    ```

    (a common hack to check this it to add a module _ : Map.S with type key = int = M after the definition of M).

I should mention that there is a way to avoid this problem: using non-toplevel code blocks (one that don't start with #), since they don't produce any output. (Also, maybe mention these exist in the readme? Finding them took a while...).

```ocaml
module M = Map.Make(Int)
```

However, it means you sometimes have to alternate code blocks frequently between toplevel/non-toplevel, which can be annoying and look a bit weird in the output.

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

No branches or pull requests

1 participant