Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000778OCamlOCaml generalpublic2002-01-04 22:562013-08-31 12:44
Reporteradministrator 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionsuspended 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000778: type constraints and interface files
DescriptionFull_Name: Dan Arnon
Version: 3.02
OS: Linux
Submission from: 63.120.156.243 (63.120.156.243)


I defined the following module type:

module type X =
  sig
    type t

    module Y:
    sig
      type t
    end
    with type t = t
  end


The type constraint at the end of the type of module Y looks cyclic, but it
shouldn't be: it basically means
that the type t of Y should be the same as the type t of X. The compiler seems
to understand that and it compiles this without any complaint. However, the .mli
file that it creates looks a bit different:

module type X =
  sig
    type t

  module Y :
                 sig
                   type t = t
                 end
 end

This is just another way to express the same constraint. So far so good.
However, when I try to compile the .mli file, I get the following error:

"The type abbreviation t is cyclic"

There is a problem here somewhere: if the compiler accepted my type definition,
and then converted it to what it considered to be an equivalent type definition,
then it should accept its own definition as well and compile it without any
complaint. If it wants to complain, it must complain about my original
definition already. If in fact the two definitions are not equivalent for some
reason, then the compiler should not convert one to the other.


TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000119)
administrator (administrator)
2002-01-07 08:25

> Full_Name: Dan Arnon
> Version: 3.02

> The type constraint at the end of the type of module Y looks cyclic, but it
> shouldn't be: it basically means
> that the type t of Y should be the same as the type t of X. The compiler
seems
> to understand that and it compiles this without any complaint. However, the
.mli
> file that it creates looks a bit different:
>
> module type X =
> sig
> type t
>
> module Y :
> sig
> type t = t
> end
> end
>
> This is just another way to express the same constraint. So far so good.

No: this one is cyclic. The only proper way to describe your type is probably
your original definition. But it would be really messy to have the
pretty-printer do that, so you will have to correct the .mli by hand until
somebody finds a better way.

A simple workaround is either to use another name for your type, or to put the
first ocurrence in another submodule.

i.e.
  module type X = sig
    module T : sig type t end
    module Y : sig type t = T.t end
  end
  module type X' = X with type T.t = int

Jacques Garrigue
(0000120)
administrator (administrator)
2002-01-07 08:26

Silly printing problem. Use workaround.
(0006612)
doligez (administrator)
2012-01-06 15:39

The pretty-printer is not absolutely guaranteed to output correct OCaml code.
This would be pretty hard to fix, and the problem is really small.

This won't be fixed in the forseeable future.

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2012-01-06 15:39 doligez Note Added: 0006612
2012-01-06 15:39 doligez Status acknowledged => resolved
2012-01-06 15:39 doligez Resolution open => suspended
2012-01-06 15:39 doligez Description Updated View Revisions
2013-08-31 12:44 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker