Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Emmanuel.Engel@lri.fr
To: caml-list@margaux.inria.fr
Subject: cl7
Date: Wed, 25 Jan 1995 11:15:45 --100	[thread overview]
Message-ID: <9501251015.AA14578@newsun8.lri.fr> (raw)


Je ne maitrise pas bien ce qui se passe et ne suis pas sur
que cela soit un bug.

Soit le fichier toto.ml suivant

****************** toto.ml *******************
#open "set";;

let emptyset = empty eq__compare;;

let add_value x = add x emptyset;;

add_value,emptyset;;

(add 1 emptyset);;

add_value,emptyset;;

*********************************************

Les surprises commencent a la compilation
camlc -c -i toto.ml
value emptyset : 'a t;;
value add_value : 'a -> 'a t;;
(* - : ('a -> 'a t) * 'a t *)            <<<<<<<<<<<< add_value,emptyset;;
(* - : int t *)               
(* - : (int t -> int t) * int t *)       <<<<<<<<<<<< add_value,emptyset;;
 
Le type de add_value et emptyset change avec le temps !?

**********************************************
Si je simplifie mon fichier et retire les trois dernieres
expressions j'ai:

****************** toto1.ml *******************
#open "set";;

let emptyset = empty eq__compare;;

let add_value x = add x emptyset;;

***********************************************

Et la j'ai un message plus explicite:

camlc -c -i toto.ml
value emptyset : 'a t;;
value add_value : 'a -> 'a t;;
The type infered for the value add_value,
that is, 'a -> 'a t,
contains type variables that cannot be generalized.

Si j'essaye de definir un cas semblable en un seul
module, je n'y arrive pas. 

***************titi.ml****************************


type 'a my_list = my_cons of ('a * 'a my_list)
                | my_nil;;

my_nil;;

let empty_list = my_nil;;

empty_list;;

empty_list = my_cons (1,my_nil);;

empty_list;;

**************************************************

camlc -c -i titi.ml 
type 'a my_list = 
    my_cons of 'a * 'a my_list
  | my_nil
;;
(* - : 'a my_list *)
value empty_list : 'a my_list;;
(* - : 'a my_list *)                       <<<<<<<<<<<<<< 
(* - : bool *)
(* - : 'a my_list *)                       <<<<<<<<<<<<<<


Dans cet exemple, le type deduit est constant.

J'ai trois questions:

1- Pourquoi ce message sur les variables de type non
   generalisables n'est-il pas affiche lors de la 
   compilation de toto.ml
   De plus est-ce une erreur ou un warning ?

2- Pourquoi ne peut-on generaliser ces variables, il n'y
   a ni reference ni mutables 

3- Visiblement la type de la fonction add_value n'est
   pas polymorphe a cause du type de emptyset qui ne l'est 
   pas. Pourquoi le message porte-t-il sur le type de 
   add_value et pas celui de emptyset


Emmanuel Engel






             reply	other threads:[~1995-02-01 17:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-01-25 12:15 Emmanuel.Engel [this message]
1995-02-01 17:35 ` cl7 Pierre Weis

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=9501251015.AA14578@newsun8.lri.fr \
    --to=emmanuel.engel@lri.fr \
    --cc=caml-list@margaux.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