caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: moosotc@gmail.com
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Interface(.mli) location
Date: Mon, 8 Aug 2016 19:03:34 +0200	[thread overview]
Message-ID: <CAPFanBFYDnUjR4c1cUykoT8ekVM4ozOchzBHZi_URkXEimZLZw@mail.gmail.com> (raw)
In-Reply-To: <8737mfp7j3.fsf@gmail.com>

It is correct that ocamldep assumes that the .ml and .mli of a given
module are at the same place, but this is not the case for the rest of
the compilation chain, which is either concerned with single source
files (a .ml file or a .mli file) or with "compilation units" (a .cmo
and .cmi files passed together, independently of where their source
files were). In particular, all type-checking tools do look in -I
directories to find .cmi files for the dependencies of the module
being compiled (and at this stage they do not care for .mli files).

On Mon, Aug 8, 2016 at 6:09 PM,  <moosotc@gmail.com> wrote:
>
> It appears that .mli ought to always reside in the same directory
> corresponding .ml lives in. Here's a simple shell script to illustrate
> (probably a good idea to run inside freshly created temporary
> directory):
>
> #!/bin/sh
> set -x
> rm -fr a* d
>
> touch a.ml
> ocamldep a.ml
> ocamlc -c a.ml || echo no cookie 1
> ls
> rm -f a* *.cm*
>
> touch a.ml a.mli
> ocamldep a.ml
> ocamlc -c a.ml || echo no cookie 2 && ls
> ocamlc -c a.mli && ls
> ocamldep a.ml
> ocamlc -c a.ml || echo no cookie 3 && ls
> rm -f a*
>
> mkdir -p d
> touch a.ml d/a.mli
> ocamldep -I d a.ml
> ocamlc -I d -c a.ml
> ls
>
> Transcript:
> + rm -fr 'a*' d
> + touch a.ml
> + ocamldep a.ml
> a.cmo :
> a.cmx :
> + ocamlc -c a.ml
> + ls
> a.cmi
> a.cmo
> a.ml
> repro.sh
> + rm -f a.cmi a.cmo a.ml a.cmi a.cmo
> + touch a.ml a.mli
> + ocamldep a.ml
> a.cmo : a.cmi
> a.cmx : a.cmi
> + ocamlc -c a.ml
> File "a.ml", line 1:
> Error: Could not find the .cmi file for interface a.mli.
> + echo no cookie 2
> no cookie 2
> + ls
> a.ml
> a.mli
> repro.sh
> + ocamlc -c a.mli
> + ls
> a.cmi
> a.ml
> a.mli
> repro.sh
> + ocamldep a.ml
> a.cmo : a.cmi
> a.cmx : a.cmi
> + ocamlc -c a.ml
> + ls
> a.cmi
> a.cmo
> a.ml
> a.mli
> repro.sh
> + rm -f a.cmi a.cmo a.ml a.mli
> + mkdir -p d
> + touch a.ml d/a.mli
> + ocamldep -I d a.ml
> a.cmo :
> a.cmx :
> + ocamlc -I d -c a.ml
> + ls
> a.cmi
> a.cmo
> a.ml
> d
> repro.sh
>
> In essence: if one needs a variant build with some module providing the
> same interface but different implementations (in different directories)
> ocaml(c|opt|dep) will force this person to have the same (stable and
> unchanging) .mli in those implementation specific directories.
>
> Section 2.5 of the manual does not specify the relative file-system
> locations of interface/implementation files, but typing/typemod.ml, if I
> am reading it correctly, forces specific layout.
>
> So it would have been nice to either lift this restriction (i.e. have
> ocaml[c|opt|dep] look inside -I supplied directories or spell out the
> requirements in the documentation.
>
> --
> mailto:moosotc@gmail.com
>
> --
> 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

  reply	other threads:[~2016-08-08 17:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 16:09 moosotc
2016-08-08 17:03 ` Gabriel Scherer [this message]
2016-08-08 17:12   ` Gerd Stolpmann
2016-08-08 17:16   ` moosotc
2016-08-08 18:30     ` David Allsopp
2016-08-08 18:57       ` moosotc
2016-08-08 19:39         ` David Allsopp
2016-08-08 19:59           ` moosotc
2016-08-08 22:54             ` David Allsopp
2016-08-09  8:45               ` SF Markus Elfring
2016-08-09 16:26                 ` David Allsopp
2016-08-09 17:55                   ` SF Markus Elfring
2016-08-09 10:56               ` moosotc
2016-08-09 11:43                 ` moosotc
2016-08-09 11:46                   ` moosotc
2016-08-09 18:08                     ` David Allsopp
2016-08-09 18:35                       ` moosotc
2016-08-09 18:59                         ` David Allsopp
2016-08-09 19:55                           ` moosotc
2016-08-10  8:20                             ` David Allsopp
2016-08-10 10:38                               ` moosotc
2016-08-09 18:33             ` David Allsopp
2016-08-09 18:38               ` moosotc
2016-08-09 19:02                 ` David Allsopp
2016-08-09  9:22           ` SF Markus Elfring
2016-08-09 16:32             ` David Allsopp
2016-08-09 18:10               ` SF Markus Elfring
2016-08-09 18:26                 ` David Allsopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPFanBFYDnUjR4c1cUykoT8ekVM4ozOchzBHZi_URkXEimZLZw@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=moosotc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).