[Ur] Passing non-Basis data types to javascript ffi?

Daniel Patterson dbp at dbpmail.net
Tue Mar 12 16:16:48 EDT 2013


Oh, that's a great workaround :)

I ended up just simplifying it - in this case, I only have one source, so I
just passed in the curried set function (I don't need to ever get the
value, but I could also pass in the curried get function). And it is
working very well - I'm happy about the division between FFI and non-FFI
code.


One odd thing about this - I have this signature in the .urs file:

val init : ...
           (float -> transaction unit) -> (* set function *)
           ...
           transaction unit

But to use that function in javascript, I need to pass it _two_ arguments,
ie, call it as execF (execF (set_function, float_value), ignored_value)) -
where, as the name indicates, the second argument seems to be ignored. It
doesn't prevent it from working, but is that expected behavior? ie is there
some extra unit argument added to functions, or something?



On Tue, Mar 12, 2013 at 3:54 PM, Adam Chlipala <adamc at csail.mit.edu> wrote:

> On 03/11/2013 07:51 PM, Daniel Patterson wrote:
>
>> My problem is just writing the type signature for the FFI signature file
>> - as mentioned in the other thread, it seems like sourceL.ur from the meta
>> repository will work for what I want, and so the signature I want to write
>> is:
>>
>> val init : id -> (* id for player container *)
>>            SourceL.t float -> (* offset source *)
>>            (SourceL.t float -> float -> transaction unit) -> (* set
>> function *)
>>            url -> (* video url *)
>>            url -> (* audio url *)
>>            transaction unit
>>
>> Which fails, because the signature file doesn't know what I mean by
>> SourceL. How can I get that in scope, or is this just not possible (because
>> I've overestimated what I can get into javascript)?
>>
>
> Hm, I can't think of a _principled_ way to do what you're asking, with the
> current Ur/Web, but here's an _un_principled solution: declare [init] as
> polymorphic in some type variable, which you then write in place of
> [SourceL.float]. :)
>
> ______________________________**_________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/**cgi-bin/mailman/listinfo/ur<http://www.impredicative.com/cgi-bin/mailman/listinfo/ur>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20130312/6c74191d/attachment.html>


More information about the Ur mailing list