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

Add (module_extensions ...) field to dune-project file #2373

Closed
wants to merge 2 commits into from

Conversation

nojb
Copy link
Collaborator

@nojb nojb commented Jul 7, 2019

This PR adds a new field (module_extensions (intf ...) (impl ...)) to dune-project that allows to specify additional extensions to be used for implementations and interfaces in addition to .ml and .mli.

The motivation is that we are porting a large code base to use dune that for historical reasons uses a different extension than the standard ones. This is a minimal addition that makes it possible for dune to handle this, and it may come in handy in other situations as well.

For simplicity, the current patch only allows to extend the set of extensions used with OCaml, Reason support could be added as well.

nojb added 2 commits July 7, 2019 22:40
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
@rgrinberg
Copy link
Member

The feature looks fine but I'm wondering if this should be an env option. It seems like something you'd only want to enable for subsets of your project where alternative extensions are allowed.

@nojb
Copy link
Collaborator Author

nojb commented Jul 8, 2019

The feature looks fine but I'm wondering if this should be an env option. It seems like something you'd only want to enable for subsets of your project where alternative extensions are allowed.

A per-project granularity is enough for my use-case; but if you think the extra generality is worth it, I can try to make it into an env option. I did not do this because the plumbing looked more complicated...

@rgrinberg
Copy link
Member

Okay, then let's not bother. However, the fact that the plumbing for for Env_node is a bit more complicated is a a general problem that needs to be solved. It should really be the same amount of difficulty.

@nojb
Copy link
Collaborator Author

nojb commented Jul 8, 2019

For symmetry I would also like to support Reason; I thought of the following syntax, which would express the default setting of dune:

(module_extensions
  (impl (ocaml ml) (reason re))
  (intf (ocaml mli) (reason rei)))

What do you think?

Also, do we want intf (resp impl) or interface (resp implementation) ?

@ghost
Copy link

ghost commented Jul 8, 2019

I have been wondering about providing first class support for defining derived languages such as reason. For instance, reason support could be defined as follow (though we'd keep it a builtin):

(define_derived_language
 (name reason)
 (file
  (kind impl)
  (extension re)
  (convert (run refmt --print binary %{input-file}))
  (format (run refmt %{input-file})))
 (file
  (kind intf)
  (extension rei)
  (convert (run refmt --print binary %{input-file}))
  (format (run refmt %{input-file}))))

convert would be used for producing a file to feed to the compiler and format would be the code formatter to use instead of ocamlformat.

That would cover this PR as well as anyone who would want to implement their own dialect of OCaml.

@nojb nojb mentioned this pull request Jul 11, 2019
@nojb
Copy link
Collaborator Author

nojb commented Jul 12, 2019

This will be fixed in a more general way by #2404

@nojb nojb closed this Jul 12, 2019
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.

2 participants