| Anonymous | Login | Signup for a new account | 2013-05-24 05:14 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||||||
| 0005714 | OCaml | OCaml typing | public | 2012-08-03 11:18 | 2012-08-03 12:07 | |||||||
| Reporter | giavitto | |||||||||||
| Assigned To | lefessan | |||||||||||
| Priority | normal | Severity | minor | Reproducibility | always | |||||||
| Status | resolved | Resolution | no change required | |||||||||
| Platform | MAC | OS | OS X | OS Version | 10.7 | |||||||
| Product Version | 4.00.0 | |||||||||||
| Target Version | Fixed in Version | |||||||||||
| Summary | 0005714: Syntax error in the signature of recursive module definitions generated by 'ocamlxxx -i' | |||||||||||
| Description | The signature of a recursive module definition raises a syntax error. It happens with the signature generated by "ocamlc -i" from a recursive module definitions. And I was unable to find the "right way" to define the signature by hand. | |||||||||||
| Steps To Reproduce | One can use the signature given in example in the documentation (http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#toc75 [^]): module rec A : sig type t = Leaf of string | Node of ASet.t val compare: t -> t -> int end and ASet : Set.S with type elt = A.t which gives Error: Syntax error at a position corresponding to the "and". The signature also be produced from of a recursive module definition using "ocamlc -i". For the example in the documentation, it gives: module rec A : sig type t = Leaf of string | Node of ASet.t val compare : t -> t -> int end and ASet : sig type elt = A.t type t val empty : t val is_empty : t -> bool val mem : elt -> t -> bool val add : elt -> t -> t val singleton : elt -> t val remove : elt -> t -> t val union : t -> t -> t val inter : t -> t -> t val diff : t -> t -> t val compare : t -> t -> int val equal : t -> t -> bool val subset : t -> t -> bool val iter : (elt -> unit) -> t -> unit val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a val for_all : (elt -> bool) -> t -> bool val exists : (elt -> bool) -> t -> bool val filter : (elt -> bool) -> t -> t val partition : (elt -> bool) -> t -> t * t val cardinal : t -> int val elements : t -> elt list val min_elt : t -> elt val max_elt : t -> elt val choose : t -> elt val split : elt -> t -> t * bool * t end which causes a syntax error located at the "and" | |||||||||||
| Tags | No tags attached. | |||||||||||
| Attached Files | ||||||||||||
Notes |
|
|
(0007882) frisch (developer) 2012-08-03 11:25 |
These are valid signature items. If you put these fragments in an .mli file, or within a "module type S = sig ... end", they work ok. You're looking for a way to define recursive module types, and as far as I know, this is not possible. |
|
(0007883) giavitto (reporter) 2012-08-03 11:38 |
Oups, you're right. This signature works in a .mli file (but then, why not in a .ml file ?). > You're looking for a way to define recursive module types Definitively. I have some complex interdependencies between types in several modules. I was hopping to define them by direct recursion. It seems that this approach is not possible. |
|
(0007884) frisch (developer) 2012-08-03 11:56 |
> This signature works in a .mli file (but then, why not in a .ml file ?). Because signature items are not a subset of structure items. For the same reason, you cannot write val x : int in an .ml file. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2012-08-03 11:18 | giavitto | New Issue | |
| 2012-08-03 11:25 | frisch | Note Added: 0007882 | |
| 2012-08-03 11:38 | giavitto | Note Added: 0007883 | |
| 2012-08-03 11:56 | frisch | Note Added: 0007884 | |
| 2012-08-03 12:07 | lefessan | Status | new => resolved |
| 2012-08-03 12:07 | lefessan | Resolution | open => no change required |
| 2012-08-03 12:07 | lefessan | Assigned To | => lefessan |
| Copyright © 2000 - 2011 MantisBT Group |