The Paradox of Partial Parametricity

Mark S. Miller erights at google.com
Fri May 10 06:05:16 PDT 2013


On Fri, May 10, 2013 at 5:55 AM, Mark S. Miller <erights at google.com> wrote:
[...]

> This same abstraction in a Q-like promise system would be written
>>
>>     class AsyncTable<t,u> {
>>         constructor() {
>>             this.m = Map<t,u>(); // encapsulation doesn't matter for this
>> example
>>         }
>>         set(keyP :Promise<t>, val :u) {
>>             keyP.then(key => { this.m.set(key, val) });
>>         }
>>         get(keyP :Promise<t>) :Promise<u> {
>>             return keyP.then(key => this.m.get(key));
>>         }
>>     }
>>
>

Actually, it's even better:


     class AsyncTable<t,u> {
         constructor() {
             this.m = Map<t,u>(); // encapsulation doesn't matter for this
example
         }
         set(keyP :Promise<t>, val :Ref<u>) {
             keyP.then(key => { this.m.set(key, val) });
         }
         get(keyP :Promise<t>) :Promise<u> {
             return keyP.then(key => this.m.get(key));
         }
     }


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130510/6e455a9f/attachment.html>


More information about the es-discuss mailing list