[TYPES] Issues regarding typeclasses and modular languages like ML

Brian Hulley brianh at metamilk.com
Fri Apr 10 16:02:38 EDT 2009


Andreas Rossberg wrote:
> [ The Types Forum, http://lists.seas.upenn.edu/mailman/listinfo/types-list ]
> 
> 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.

Thanks Andreas, that last detail makes everything crystal clear.
Also, thanks Derek for the explanation showing how one would translate the above into the context of MTC.

Best regards,
Brian.




More information about the Types-list mailing list