You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5714 Reporter: giavitto Assigned to:@lefessan Status: closed (set by @xavierleroy on 2015-12-11T18:07:33Z) Resolution: not a bug Priority: normal Severity: minor Platform: MAC OS: OS X OS Version: 10.7 Version: 4.00.0 Category: typing
Bug 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.
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"
The text was updated successfully, but these errors were encountered:
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.
Original bug ID: 5714
Reporter: giavitto
Assigned to: @lefessan
Status: closed (set by @xavierleroy on 2015-12-11T18:07:33Z)
Resolution: not a bug
Priority: normal
Severity: minor
Platform: MAC
OS: OS X
OS Version: 10.7
Version: 4.00.0
Category: typing
Bug 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"
The text was updated successfully, but these errors were encountered: