[TYPES] Issues regarding typeclasses and modular languages like ML

Andreas Rossberg rossberg at mpi-sws.org
Fri Apr 10 07:57:49 EDT 2009


On Apr 10, 2009, at 02.37 h, Derek Dreyer wrote:
>
>> Thanks for elucidating the relevance of [2] and [3] to my  
>> questions. If I've now understood things right, then I assume that  
>> in the example below (in the language of [3]), the sealing  
>> operation has actually done something quite interesting: not only  
>> has it created a new statically distinct type (t) but it has also  
>> created a new instance declaration (instance t C) that is  
>> implemented by the instance declaration (instance int C) inside M.
>>
>>
>>  class 'a C with ...
>>
>>  structure M = struct
>>     type t = int
>>     instance int C with ...
>>  end
>>
>>  structure N = M :> sig
>>       type t
>>       instance t C
>>  end
>
> Hmm...well, just to clarify: MTC does not include explicit "class" or
> "instance" declarations...that's the whole point.

(Brian is using the syntax from Gerhard's thesis here.)

Yes, what you are describing above is what's happening. There is one  
additional detail, though: neither instance will initially be "active"  
outside the structures, because they are local to those structures.  
You would have to open the structures, or use the TML syntax for  
instance replication to pull them into global scope. That is similar  
in effect to the "using" declarations Derek was describing.

- Andreas



More information about the Types-list mailing list