Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Emmanuel Engel <Emmanuel.Engel@lri.fr>
To: caml-list@inria.fr
Subject: Some cosmetics problems with ocaml
Date: Mon, 18 Nov 1996 16:23:50 +0100	[thread overview]
Message-ID: <32907F85.15BC@lri.fr> (raw)

I have some cosmetics problems with ocaml. 

First it is not possible to simply create mli files with the command 
"ocamlc -c -i fool.ml > foo.mli". There is at least three reasons.

First the compiler complain that we must  compile interface file first. 
I need a compilation option to solve this problem. Something saying 
"generate .mli file forme infered type" will be OK.

I can try "ocamlc -c -i foo.ml > a;mv a foo.mli". But again I have some 
problems. 

The first problem is that I have no solution to suppress warnings from  
the compiler output. So if i try to compile the following file with 
  
**** foo.ml *******

let f 1 = 1 
 
******************

the resulting a file will be

******** foo.mli ********
File "foo.ml", line 1, characters 6-10:
Warning: this pattern-matching is not exhaustive
val f : int -> int
*************************

This file does not compile.


The second problem is with mutualy recursives type 
definitions.


**** foo.ml ******************

type foo = N
         | C of int * froz ref

and  froz = V of foo
	  | T of (unit -> foo)  
*******************************

the resulting foo.mli will be :

********* foo.mli *************
type foo = N | C of int * froz ref
type froz = V of foo | T of (unit -> foo)
*******************************

This file does not compile.

That's all for interfaces. Let's talk about modules. 

Sometimes I want to define sets or map or somethings else for 
a specifics data structure. I used to put the module set inside 
the module that define the data structure. I want to extend the 
function that I have defined for my data structure to sets. I 
find usefull to keep the same name for the function's extension 
but this is quite difficult: I can't refer to a function with is 
fully qualified name inside the module definition. 

Let's take an example. I'd like to write:

************* foo.ml ********************
type foo = N
         | C of int * froz ref

and  froz = V of foo
	  | T of (unit -> foo)  


let rec eval_all = function
    C(_,{contents=V x}) -> 
      eval_all x;
  | C(_,({contents=T f} as t)) ->
      let v= f () in
      t.contents <- (V v);
      v;
  | _  ->
      ()

module FooSet=
  struct
    type t = int list 
    let rec eval_all = function
      |	[]     ->
	  ()
      |	hd::tl ->
	  (Foo.eval_all hd);
          (Foo.FooSet.eval_all tl)
  end
*******************************************************


The problem is the last function eval_all. The values Foo.eval_all
and Foo.FooSet.eval_all are undefined. I must write something like


let eval_all = 
  let rec f = function
     []   ->
       ()
    |hd::tl ->
        (eval_all hd);
        (f tl) in f

I find it less practical. 

-- 

- Emmanuel Engel





             reply	other threads:[~1996-11-19 15:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-18 15:23 Emmanuel Engel [this message]
1996-11-19 16:35 ` Wolfgang Lux

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=32907F85.15BC@lri.fr \
    --to=emmanuel.engel@lri.fr \
    --cc=caml-list@inria.fr \
    /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