Browse thread
Weird behavior with mutually recursive type definitions
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Hendrik Tews <tews@t...> |
| Subject: | Re: Weird behavior with mutually recursive type definitions |
Francois Pottier writes:
Date: Wed, 4 Aug 1999 15:52:39 +0200
Subject: Weird behavior with mutually recursive type definitions
[...]
type 'a t = 'a dummy
and specialized = int t
O'Caml still accepts the code, but this time, it constrains 'a
to be equal to int, as if the type constructor t could not be
used polymorphically within its own declaration:
type 'a t = 'a dummy constraint 'a = int
^^^^^^^^^^^^^^^^^^^
type specialized = int t
Why is this? Can someone explain, or is it a typechecker bug?
A few month ago we run into the same problem. From a private
conversation with Jacques Garrigue I understood, that the above
behavior is actually a feature of the typechecker, because there
is no better solution known at the moment. :-(
We solved the problem by eliminating type abbreviations (by
replacing it with its expansion) until these constraints
vanished. (You can use option ocamlc -i on your code to see which
constraints are generated.) The elimination of the abbreviations
leads to ugly and unreadable code, but it works at least.
Hope this helps,
Hendrik