caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] getting rid of ocamlbuild's .mlpack files in a project
@ 2015-08-20 13:36 Francois Berenger
  2015-08-20 14:01 ` Fabrice Le Fessant
  0 siblings, 1 reply; 2+ messages in thread
From: Francois Berenger @ 2015-08-20 13:36 UTC (permalink / raw)
  To: caml users

Dear list,

Just a quick note for posterity on how to remove a .mlpack file
from a project, since Google was not my friend on this subject.

.mlpack files are a feature supported by ocamlbuild.
As documented in section 18.3.16 of
http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual032.html

I think only ocamlbuild supports .mlpack files.
So, you might want to get rid of them because you are switching
a project to another build system.
Or, maybe, you want the "feature" without becoming bound to ocamlbuild.

In any case, here is a recipe that works for me.

I replaced the file

util.mlpack
---
util/Toto
---

by the file

util.mlp
---
module Toto :
sig
#include "util/toto.mli"
end = struct
#include "util/toto.ml"
end
---

Then, using the excellent cppo ocaml preprocessor from Martin Jambon,
you can do:

cppo util.mlp > util.ml

I think this util.ml file does explicitely what the util.mlpack file was 
doing when processed by ocamlbuild, at the cost of a preprocessing step.

Best regards,
Francois.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] getting rid of ocamlbuild's .mlpack files in a project
  2015-08-20 13:36 [Caml-list] getting rid of ocamlbuild's .mlpack files in a project Francois Berenger
@ 2015-08-20 14:01 ` Fabrice Le Fessant
  0 siblings, 0 replies; 2+ messages in thread
From: Fabrice Le Fessant @ 2015-08-20 14:01 UTC (permalink / raw)
  To: Francois Berenger; +Cc: caml users

Well, that would work for non-recursive modules. If you have recursive
modules (for example, A contains "val f : t -> B.t" and B contains
"val f : t -> A.t"), you will need to use recursive modules "module
rec Toto ..." and find two limitations :
1/ "module rec" requires all your modules to have a signature, whereas
your .mlpack file could contain modules without .mli files, and still
work with recursive modules
2/ the shape and ordering of modules in "module rec" is limited, and
it is possible to have recursive toplevel modules that can just not be
included in a "module rec": for example, if you use a toplevel
"include" in one of the modules.

There is a tool that does automatically what you did: see "ocp-pack" in
http://www.ocamlpro.com/blog/2011/08/10/ocaml-pack-functors.html

I used it on Alt-Ergo, and could not compile it because of the above
restrictions...

--Fabrice


On Thu, Aug 20, 2015 at 3:36 PM, Francois Berenger
<francois.berenger@inria.fr> wrote:
> Dear list,
>
> Just a quick note for posterity on how to remove a .mlpack file
> from a project, since Google was not my friend on this subject.
>
> .mlpack files are a feature supported by ocamlbuild.
> As documented in section 18.3.16 of
> http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual032.html
>
> I think only ocamlbuild supports .mlpack files.
> So, you might want to get rid of them because you are switching
> a project to another build system.
> Or, maybe, you want the "feature" without becoming bound to ocamlbuild.
>
> In any case, here is a recipe that works for me.
>
> I replaced the file
>
> util.mlpack
> ---
> util/Toto
> ---
>
> by the file
>
> util.mlp
> ---
> module Toto :
> sig
> #include "util/toto.mli"
> end = struct
> #include "util/toto.ml"
> end
> ---
>
> Then, using the excellent cppo ocaml preprocessor from Martin Jambon,
> you can do:
>
> cppo util.mlp > util.ml
>
> I think this util.ml file does explicitely what the util.mlpack file was
> doing when processed by ocamlbuild, at the cost of a preprocessing step.
>
> Best regards,
> Francois.
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs



-- 
Fabrice LE FESSANT
Chercheur en Informatique
INRIA Paris Rocquencourt -- OCamlPro
Programming Languages and Distributed Systems

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-20 14:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-20 13:36 [Caml-list] getting rid of ocamlbuild's .mlpack files in a project Francois Berenger
2015-08-20 14:01 ` Fabrice Le Fessant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).