[Ur] introducing a name in functor body

Adam Chlipala adamc at impredicative.com
Thu Dec 1 09:15:17 EST 2011


Adam Chlipala wrote:
> Gergely Buday wrote:
>> functor Main(M: sig end ) : sig val foo : int  end =
>> struct
>>    open M
>>
>>    con Field :: Name
>>
>>    val foo = 3
>> end
>>
>> What is wrong with this?
>
> The problem is the same as if you had merely written [val foo : int] 
> instead of [val foo = 3]: you are writing an _interface_ declaration 
> (i.e., "signature item") in a position that expects an 
> _implementation_ declaration (just called "declaration" in the 
> manual).  There is no declaration for generating a fresh name 
> automatically; you would probably take that name into the functor as 
> an input.

Also, variable names must begin with lowercase letters, while you are 
using a capitalized identifier here.  The constant [#Field] (of kind 
[Name]) already exists, without any declaration.



More information about the Ur mailing list