[Ur] About clientOnly

Aistis Raulinaitis sheganinans at gmail.com
Sun May 21 20:22:21 EDT 2017


So I am working with the JS FFI, however it seems that the clientOnly
directive is being ignored.

Here is the example code:

~~~
main.urp:
~~~

ffi js_map
jsFunc Js_map.new_map=new_map
jsFunc Js_map.new_map_with=new_map_with
clientOnly Js_map.new_map
clientOnly Js_map.new_map_with
benignEffectful Js_map.new_map
benignEffectful Js_map.new_map_with
jsFile js_map.js

main


~~~
main.urs:
~~~

val main : unit -> transaction page


~~~
main.ur:
~~~

fun main () =
    c <- Js_map.new_map_with ((1, 2)::[]);
    return <xml></xml>


~~~
js_map.urs:
~~~

con js_map :: Type -> Type -> Type

val new_map      : k ::: Type -> v ::: Type -> unit -> transaction (js_map
k v)
val new_map_with : k ::: Type -> v ::: Type -> list (k * v) -> transaction
(js_map k v)


~~~
js_map.js:
~~~

function new_map () {return new Map ();}

function new_map_with (arg) {return new Map (arg); }


~~~
So in main.ur, you can see that I am calling this Js code in a C context,
instead of getting an error complaining about how it should be called on
the client, instead I get this confusing error:

urweb main
/Users/ace/src/cli_only/js_map.urs:4:75: (to 4:87) Unsupported type
constructor
Constructor:  FFI(Js_map.js_map_with) FFI(Basis.int) FFI(Basis.int)
/usr/local/Cellar/urweb/20170105/lib/urweb/ur/basis.urs:127:23: (to 127:25)
Unsupported type constructor
Constructor:  FFI(Js_map.js_map_with) FFI(Basis.int) FFI(Basis.int)
make: *** [all] Error 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20170521/c6bc12b2/attachment.html>


More information about the Ur mailing list