* Re: type declaration in */mli & *.ml
@ 1997-10-01 10:02 Hendrik Tews
1997-10-04 15:14 ` kahl
0 siblings, 1 reply; 6+ messages in thread
From: Hendrik Tews @ 1997-10-01 10:02 UTC (permalink / raw)
To: caml-list-request
Hi,
I am writing again about a topic we had on the list last year
(cf. http://pauillac.inria.fr/caml/caml-list/0676.html and
http://pauillac.inria.fr/caml/caml-list/0680.html).
As Xavier writes it is a pain that in some circumstances
(specifications of types and signatures) the same code has to be
written twice, first in the specification and then in the
implementation.
Is there any solution to this?
Has anybody tried to include parts of an interface into an
implementation (for instance by means of a preprocessor)?
Greetings,
Hendrik
-------------------------------------------------------------
e-mail: tews@tcs.inf.tu-dresden.de
www: http://wwwtcs.inf.tu-dresden.de/~tews
-------------------------------------------------------------
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: type declaration in */mli & *.ml
1997-10-01 10:02 type declaration in */mli & *.ml Hendrik Tews
@ 1997-10-04 15:14 ` kahl
0 siblings, 0 replies; 6+ messages in thread
From: kahl @ 1997-10-04 15:14 UTC (permalink / raw)
To: tews; +Cc: caml-list
Hendrik Tews writes:
> I am writing again about a topic we had on the list last year
> (cf. http://pauillac.inria.fr/caml/caml-list/0676.html and
> http://pauillac.inria.fr/caml/caml-list/0680.html).
> As Xavier writes it is a pain that in some circumstances
> (specifications of types and signatures) the same code has to be
> written twice, first in the specification and then in the
> implementation.
> Is there any solution to this?
> Has anybody tried to include parts of an interface into an
> implementation (for instance by means of a preprocessor)?
I am using FunnelWeb (a language-independent literate programming system)
for almost everything, and it is a nice solution to this problem, too.
For my current project, I edit a single FunnelWeb file (currently >800k)
in the folding-mode of Emacs, and a single run of FunnelWeb
(8 seconds on a SparcStation 20) produces a Makefile, 48 OLabl modules
with interfaces, among these 4 lexers and 4 parsers, several special
auxiliary files, and a LaTeX file containing 400+ pages of documented code.
The documented code in the literate programming style can be very nice
and useful, but even if you do not want to go literate,
FunnelWeb is still a very useful preprocessor
(I must admit that I am sometimes lazy on documentation, too...)
FunnelWeb is available via:
URL: http://www.ross.net/funnelweb/introduction.html
There is also a modified version (which I haven't tried yet)
that allows HTML output and line directives:
URL: http://www.physics.uq.oz.au:8001/people/coates/funnelweb.html
Happy weaving!
Wolfram
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: type declaration in */mli & *.ml
1997-10-03 16:34 Manuel Fahndrich
@ 1997-10-06 11:51 ` U-E59264-Osman Buyukisik
0 siblings, 0 replies; 6+ messages in thread
From: U-E59264-Osman Buyukisik @ 1997-10-06 11:51 UTC (permalink / raw)
To: caml-list
Since I have seen a couple of litprog tools mentioned, I will add a
little to the discussion. There are a number of litprog tools
available for this purpose: nuweb/noweb/funnelweb/CLiP etc that I
would suggest looking at the litprog FAQ (at the usual places), and
then making your own decision. noweb/nuweb are easy to learn (a few
pages of docs). Others have more features/take more time to get
proficient at. There is a news group comp.programming.literate.
Osman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: type declaration in */mli & *.ml
@ 1997-10-03 16:34 Manuel Fahndrich
1997-10-06 11:51 ` U-E59264-Osman Buyukisik
0 siblings, 1 reply; 6+ messages in thread
From: Manuel Fahndrich @ 1997-10-03 16:34 UTC (permalink / raw)
To: caml-list
Hendrik Tews <tews@tcs.inf.tu-dresden.de> wrote
[...]
>Has anybody tried to include parts of an interface into an
>implementation (for instance by means of a preprocessor)?
I've seen SML programs written using NoWeb, a variant of Knuth's
literate programming tool Web. The tool acts as a preprocessor and
makes it easy to write type declarations only once, and use them in
signatures and structures.
-Manuel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: type declaration in */mli & *.ml
1996-10-21 9:23 Basile STARYNKEVITCH
@ 1996-10-23 9:29 ` Xavier Leroy
0 siblings, 0 replies; 6+ messages in thread
From: Xavier Leroy @ 1996-10-23 9:29 UTC (permalink / raw)
To: Basile STARYNKEVITCH; +Cc: caml-list
> It seems that when a type is declared in the interface of a module Moo
> -ie in the file moo.mli- it should also be declared in the
> implementation of the same module Moo -ie in the file moo.ml-.
> I don't understand why is it so, and I feel such a redundancy is very
> annoying.
It's a pain, all right, but the explanation is very simple in terms of
module interfaces (specifications) and module implementations.
When a .mli file, or equivalently a sig ... end module type, contains
type t = A of ... | B of ...
that's just a specification saying that any implementation of this
interface (that is, the .ml file or any structure that is matched
against the interface) must define a type t with the same
constructors and arguments. The type t could also be specified
abstract, as in:
type t
in which case the implementation can define t as any constant type.
In both cases, the implementation must provide a definition for t.
Of course, if t is specified manifest, this does not leave much
flexibility for the definition of t in the implementation, which is
usually identical to the specification in the interface.
When using the full module calculus, an implementation (struct...end)
can have several interfaces (sig...end), and an interface can have
several implementations, so it's not possible in general to have automatic
definitions of types in the implementation based on the manifest
declarations in the interface.
> (perhaps I could paraphrase my question: does an implementation file
> moo.ml of a module Moo contain an implicit open Moo;; ??)
The answer is no, and this would not make sense, since "open" can only
apply to an implementation, not an interface (again, there might be
several implementations of a given interface), so you would be opening
the implementation you're currently defining.
- Xavier Leroy
^ permalink raw reply [flat|nested] 6+ messages in thread
* type declaration in */mli & *.ml
@ 1996-10-21 9:23 Basile STARYNKEVITCH
1996-10-23 9:29 ` Xavier Leroy
0 siblings, 1 reply; 6+ messages in thread
From: Basile STARYNKEVITCH @ 1996-10-21 9:23 UTC (permalink / raw)
To: caml-list
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1988 bytes --]
Hello All,
It seems that when a type is declared in the interface of a module Moo
-ie in the file moo.mli- it should also be declared in the
implementation of the same module Moo -ie in the file moo.ml-.
For instance, in directory ocaml-1.02/toplevel the file toploop.mli
contains
(*################ from toplevel/toploop.mli *)
(* Interface with toplevel directives *)
type directive_fun =
Directive_none of (unit -> unit)
| Directive_string of (string -> unit)
| Directive_int of (int -> unit)
| Directive_ident of (Longident.t -> unit)
(*############### end of sample ################*)
while the file toploop.ml also contains
(*############# from toplevel/toploop.ml ################*)
type directive_fun =
Directive_none of (unit -> unit)
| Directive_string of (string -> unit)
| Directive_int of (int -> unit)
| Directive_ident of (Longident.t -> unit)
(*################ end of sample ################*)
I don't understand why is it so, and I feel such a redundancy is very
annoying.
Any hints or explanations?
(perhaps I could paraphrase my question: does an implementation file
moo.ml of a module Moo contain an implicit open Moo;; ??)
Thanks for reading.
N.B. Any opinions expressed here are solely mine, and not of my organization.
N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA.
Please cite a *pertinent part* of my mail in all answers
Veuillez citer une *partie pertinente* de mon courrier dans vos reponses
----------------------------------------------------------------------
Basile STARYNKEVITCH ---- Commissariat à l Energie Atomique
DRN/DMT/SERMA * CEA/Saclay bat.470 * 91191 GIF/YVETTE CEDEX * France
fax: (33) 01,69.08.85.68; phone: 01,69.08.40.66; home: 01,46.65.45.53
email: Basile.Starynkevitch@cea.fr (or else basile@soleil.serma.cea.fr);
I speak french, english, russian. Je parle français, anglais, russe.
----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1997-10-06 16:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-01 10:02 type declaration in */mli & *.ml Hendrik Tews
1997-10-04 15:14 ` kahl
-- strict thread matches above, loose matches on Subject: below --
1997-10-03 16:34 Manuel Fahndrich
1997-10-06 11:51 ` U-E59264-Osman Buyukisik
1996-10-21 9:23 Basile STARYNKEVITCH
1996-10-23 9:29 ` Xavier Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox