caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: Strange type error
@ 2000-10-24 16:47 Brent Fulgham
  0 siblings, 0 replies; 4+ messages in thread
From: Brent Fulgham @ 2000-10-24 16:47 UTC (permalink / raw)
  To: caml-list

> I had a similar problem some time ago. This strange behavior of O'Caml
> 3.00 was corrected in the CVS version:
> 
> ------------------------------------------------------
>         Objective Caml version 3.00
> 
> # type 'a section_path = { x : int; }
>     and mind_section_path = [ `MIND] section_path
>     ;;
> type [ `MIND] section_path = { x : int; }  constraint [ `MIND] = [
> `MIND]
> type mind_section_path = [ `MIND] section_path
> # 
> ------------------------------------------------------
>         Objective Caml version 3.00+8 (2000-06-30)
> 
> # type 'a section_path = { x : int; }
>     and mind_section_path = [ `MIND] section_path
>     ;;
>     type 'a section_path = { x : int; } 
> type mind_section_path = [ `MIND] section_path
> # 
> ------------------------------------------------------
> 

With this fix, and the ICFP-discovered bug fix, does anyone
think it's time to create a 3.01 tarball/binary distribution
as a "stable" release?

Thanks,

-Brent 



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

* Re: Strange type error
  2000-10-23 15:35 Claudio Sacerdoti Coen
  2000-10-24  7:05 ` Judicael Courant
@ 2000-10-24  7:35 ` Jacques Garrigue
  1 sibling, 0 replies; 4+ messages in thread
From: Jacques Garrigue @ 2000-10-24  7:35 UTC (permalink / raw)
  To: sacerdot; +Cc: caml-list

From: Claudio Sacerdoti Coen <sacerdot@students.cs.unibo.it>

>  let a.mli be
> 
>   type 'a section_path = { x : int; }
>   and mind_section_path = [ `MIND] section_path
>   type const_section_path = [ `CONST] section_path
> 
>  and b.mli be
> 
>  type 'a section_path = { x : int; }
>  type mind_section_path = [ `MIND] section_path
>  type const_section_path = [ `CONST] section_path
> 
>  b.mli is compiled without problems, but for a.mli I get
> 
>  File "prova.mli", line 3, characters 26-35:
>  This type [ `CONST] should be an instance of type [ `MIND]
> 
>  that seems nonsense to me. Someone could explain the error?

For a long time, the answer was: "this is not a bug, this is a
feature." (cf. this mailing list more than 1 year ago)
That is, in recursive type definitions, as in recursive value
definitions, the polymorphism is only given after a definition block
is finished. As a result, the definition in a.mli actually means:
        type 'a section_path = { x : int } constraint 'a = [ `MIND]
You can see it by doing `ocamlc -i -c a.mli'.

In the current version (upcoming 3.01), this problem is solved:
type definitions are assumed to be polymorphic, and if you want the
above behavior you must explicitly request it. As a result a.mli and
b.mli become equivalent. So we can now assume that this was a bug.

Cheers,

Jacques Garrigue
---------------------------------------------------------------------------
Jacques Garrigue      Kyoto University     garrigue at kurims.kyoto-u.ac.jp
		<A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>



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

* Re: Strange type error
  2000-10-23 15:35 Claudio Sacerdoti Coen
@ 2000-10-24  7:05 ` Judicael Courant
  2000-10-24  7:35 ` Jacques Garrigue
  1 sibling, 0 replies; 4+ messages in thread
From: Judicael Courant @ 2000-10-24  7:05 UTC (permalink / raw)
  To: Claudio Sacerdoti Coen; +Cc: caml-list

Claudio Sacerdoti Coen a écrit :
> 
>  Hello,
> 
>  let a.mli be
> 
>   type 'a section_path = { x : int; }
>   and mind_section_path = [ `MIND] section_path
>   type const_section_path = [ `CONST] section_path
[...]
> for a.mli I get
> 
>  File "prova.mli", line 3, characters 26-35:
>  This type [ `CONST] should be an instance of type [ `MIND]
> 
>  that seems nonsense to me. Someone could explain the error?
> 

I had a similar problem some time ago. This strange behavior of O'Caml
3.00 was corrected in the CVS version:

------------------------------------------------------
        Objective Caml version 3.00

# type 'a section_path = { x : int; }
    and mind_section_path = [ `MIND] section_path
    ;;
type [ `MIND] section_path = { x : int; }  constraint [ `MIND] = [
`MIND]
type mind_section_path = [ `MIND] section_path
# 
------------------------------------------------------
        Objective Caml version 3.00+8 (2000-06-30)

# type 'a section_path = { x : int; }
    and mind_section_path = [ `MIND] section_path
    ;;
    type 'a section_path = { x : int; } 
type mind_section_path = [ `MIND] section_path
# 
------------------------------------------------------

Judicaël.
-- 
Judicael.Courant@lri.fr, http://www.lri.fr/~jcourant/
(+33) (0)1 69 15 64 85
"Montre moi des morceaux de ton monde, et je te montrerai le mien"
Tim, matricule #929, condamné à mort.
http://rozenn.picard.free.fr/tim.html



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

* Strange type error
@ 2000-10-23 15:35 Claudio Sacerdoti Coen
  2000-10-24  7:05 ` Judicael Courant
  2000-10-24  7:35 ` Jacques Garrigue
  0 siblings, 2 replies; 4+ messages in thread
From: Claudio Sacerdoti Coen @ 2000-10-23 15:35 UTC (permalink / raw)
  To: caml-list

 Hello,

 let a.mli be

  type 'a section_path = { x : int; }
  and mind_section_path = [ `MIND] section_path
  type const_section_path = [ `CONST] section_path

 and b.mli be

 type 'a section_path = { x : int; }
 type mind_section_path = [ `MIND] section_path
 type const_section_path = [ `CONST] section_path

 b.mli is compiled without problems, but for a.mli I get

 File "prova.mli", line 3, characters 26-35:
 This type [ `CONST] should be an instance of type [ `MIND]

 that seems nonsense to me. Someone could explain the error?

 						Thanks,
						C.S.C.

-- 
----------------------------------------------------------------
Real name: Claudio Sacerdoti Coen
Graduate Computer Science Student at University of Bologna
Now at INRIA (Rocquencourt)
E-mail: sacerdot@cs.unibo.it
        Claudio.Sacerdoti_Coen@inria.fr
http://caristudenti.cs.unibo.it/~sacerdot
----------------------------------------------------------------



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

end of thread, other threads:[~2000-10-25 18:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-24 16:47 Strange type error Brent Fulgham
  -- strict thread matches above, loose matches on Subject: below --
2000-10-23 15:35 Claudio Sacerdoti Coen
2000-10-24  7:05 ` Judicael Courant
2000-10-24  7:35 ` Jacques Garrigue

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).