Julien Blond wrote:
> 2016-11-25 9:39 GMT+01:00 Julien Blond <mailto:julien.blond@gmail.com>: As you've observed, [] is a variant constructor since 4.03.0 - see GPR#234 (https://github.com/ocaml/
> Hi,
> Let's try something :
> $ ocaml
> OCaml version 4.03.0
>
> # let _ : [] list = [];;
> Characters 9-10:
> let _ : [] list = [];;
> Error: Syntax error
> # type empty = [];;
> type empty = []
> # let _ : empty list = [];;
> - : empty list = []
> #
>
> Does anyone know if there is a reason to forbid the empty polymorphic variant
> set in type expressions or if it's a bug ?
ocaml/pull/234 ). The GPR contains references and comments as to the motivation for this.
What's your desired use for the type of the non-extensible empty polymorphic variant?
Possibly related, you can define a general type for a list of polymorphic variants:
let (empty : [> ] list) = []
or
let (length : [> ] list -> int) = List.length;;
length [`Foo; `Bar];;
length [42];;
if that's what you were after?
David