Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
As-binding #-types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1996-09-12 (15:06)
From: Jerome Vouillon <vouillon@c...>
Subject: Re: As-binding #-types

>   #type 'a mytype = Mk of #myclass as 'a;;
>   Unbound row variable in #myclass

In a type definition, type parameters *must* be free variables. But, here,
you try to bind the type parameter 'a to #myclass. So, this definition
fails. Actually, the compiler sees that #myclass contains a row variable
that obviously cannot be a type parameter, and hence rejects this phrase.

You can remove the constraint and just write
    #type 'a mytype = Mk of 'a;;
I don't think omitting the type constraint is a problem in practice.

However, I plan to add constrained type definitions to the language in the
future. Then you will probably be able to write your type definition as
    #type (#myclass as 'a) mytype = Mk of 'a;;