<div dir="ltr">Hmm, that makes sense. Do you have an example of FFI with an abstract type? I tried to encapsulate the map type with a con, but obviously that does not work..<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 21, 2017 at 8:10 PM, Artyom Shalkhakov <span dir="ltr"><<a href="mailto:artyom.shalkhakov@gmail.com" target="_blank">artyom.shalkhakov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">2017-05-22 6:22 GMT+06:00 Aistis Raulinaitis <<a href="mailto:sheganinans@gmail.com">sheganinans@gmail.com</a>>:<br>
> So I am working with the JS FFI, however it seems that the clientOnly<br>
> directive is being ignored.<br>
><br>
> Here is the example code:<br>
><br>
> ~~~<br>
> main.urp:<br>
> ~~~<br>
><br>
> ffi js_map<br>
> jsFunc Js_map.new_map=new_map<br>
> jsFunc Js_map.new_map_with=new_map_<wbr>with<br>
> clientOnly Js_map.new_map<br>
> clientOnly Js_map.new_map_with<br>
> benignEffectful Js_map.new_map<br>
> benignEffectful Js_map.new_map_with<br>
> jsFile js_map.js<br>
><br>
> main<br>
><br>
><br>
> ~~~<br>
> main.urs:<br>
> ~~~<br>
><br>
> val main : unit -> transaction page<br>
><br>
><br>
> ~~~<br>
> main.ur:<br>
> ~~~<br>
><br>
> fun main () =<br>
> c <- Js_map.new_map_with ((1, 2)::[]);<br>
> return <xml></xml><br>
><br>
><br>
> ~~~<br>
> js_map.urs:<br>
> ~~~<br>
><br>
> con js_map :: Type -> Type -> Type<br>
><br>
> val new_map : k ::: Type -> v ::: Type -> unit -> transaction (js_map k<br>
> v)<br>
> val new_map_with : k ::: Type -> v ::: Type -> list (k * v) -> transaction<br>
> (js_map k v)<br>
><br>
><br>
> ~~~<br>
> js_map.js:<br>
> ~~~<br>
><br>
> function new_map () {return new Map ();}<br>
><br>
> function new_map_with (arg) {return new Map (arg); }<br>
><br>
><br>
> ~~~<br>
> So in main.ur, you can see that I am calling this Js code in a C context,<br>
> instead of getting an error complaining about how it should be called on the<br>
> client, instead I get this confusing error:<br>
><br>
> urweb main<br>
> /Users/ace/src/cli_only/js_<wbr>map.urs:4:75: (to 4:87) Unsupported type<br>
> constructor<br>
> Constructor: FFI(Js_map.js_map_with) FFI(Basis.int) FFI(Basis.int)<br>
> /usr/local/Cellar/urweb/<wbr>20170105/lib/urweb/ur/basis.<wbr>urs:127:23: (to 127:25)<br>
> Unsupported type constructor<br>
> Constructor: FFI(Js_map.js_map_with) FFI(Basis.int) FFI(Basis.int)<br>
> make: *** [all] Error 1<br>
><br>
<br>
</div></div>I got the impression that Ur/Web being a whole-program optimizing<br>
compiler, the only types being supported for marshalling between FFI<br>
code and non-FFI code are primitive types and abstract types. I think<br>
I asked this same question some time ago.<br>
<br>
So it looks like you will have to work around this somehow.<br>
<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> Ur mailing list<br>
> <a href="mailto:Ur@impredicative.com">Ur@impredicative.com</a><br>
> <a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" rel="noreferrer" target="_blank">http://www.impredicative.com/<wbr>cgi-bin/mailman/listinfo/ur</a><br>
><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
Cheers,<br>
Artyom Shalkhakov<br>
<br>
______________________________<wbr>_________________<br>
Ur mailing list<br>
<a href="mailto:Ur@impredicative.com">Ur@impredicative.com</a><br>
<a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" rel="noreferrer" target="_blank">http://www.impredicative.com/<wbr>cgi-bin/mailman/listinfo/ur</a><br>
</font></span></blockquote></div><br></div>