[Ur] About clientOnly
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 ~~~ 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 ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] About clientOnly
2017-05-22 6:22 GMT+06:00 Aistis Raulinaitis : > 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 > > > ~~~ > 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 > I got the impression that Ur/Web being a whole-program optimizing compiler, the only types being supported for marshalling between FFI code and non-FFI code are primitive types and abstract types. I think I asked this same question some time ago. So it looks like you will have to work around this somehow. > > > ___ > Ur mailing list > Ur@impredicative.com > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > -- Cheers, Artyom Shalkhakov ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] About clientOnly
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.. On Sun, May 21, 2017 at 8:10 PM, Artyom Shalkhakov < artyom.shalkha...@gmail.com> wrote: > 2017-05-22 6:22 GMT+06:00 Aistis Raulinaitis : > > 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 > > > > > > ~~~ > > 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 > > > > I got the impression that Ur/Web being a whole-program optimizing > compiler, the only types being supported for marshalling between FFI > code and non-FFI code are primitive types and abstract types. I think > I asked this same question some time ago. > > So it looks like you will have to work around this somehow. > > > > > > > ___ > > Ur mailing list > > Ur@impredicative.com > > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > > > > > > -- > Cheers, > Artyom Shalkhakov > > ___ > Ur mailing list > Ur@impredicative.com > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] About clientOnly
2017-05-22 9:19 GMT+06:00 Aistis Raulinaitis : > 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.. > Sure, here are two examples: https://github.com/bbarenblat/urweb-regex (in particular, take a look at regex__FFI.urs and the two types [substring_t] and [substring_list_t]) https://github.com/ashalkhakov/urweb-storage (shameless plug; in particular, take a look at storage__FFI.urs and the type [storage]) > On Sun, May 21, 2017 at 8:10 PM, Artyom Shalkhakov > wrote: >> >> 2017-05-22 6:22 GMT+06:00 Aistis Raulinaitis : >> > 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 >> > >> > >> > ~~~ >> > 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 >> > >> >> I got the impression that Ur/Web being a whole-program optimizing >> compiler, the only types being supported for marshalling between FFI >> code and non-FFI code are primitive types and abstract types. I think >> I asked this same question some time ago. >> >> So it looks like you will have to work around this somehow. >> >> > >> > >> > ___ >> > Ur mailing list >> > Ur@impredicative.com >> > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >> > >> >> >> >> -- >> Cheers, >> Artyom Shalkhakov >> >> ___ >> Ur mailing list >> Ur@impredicative.com >> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > > > > ___ > Ur mailing list > Ur@impredicative.com > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > -- Cheers, Artyom Shalkhakov ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] About clientOnly
Thanks! On Sun, May 21, 2017 at 8:27 PM, Artyom Shalkhakov < artyom.shalkha...@gmail.com> wrote: > 2017-05-22 9:19 GMT+06:00 Aistis Raulinaitis : > > 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.. > > > > Sure, here are two examples: > > https://github.com/bbarenblat/urweb-regex (in particular, take a look > at regex__FFI.urs and the two types [substring_t] and > [substring_list_t]) > https://github.com/ashalkhakov/urweb-storage (shameless plug; in > particular, take a look at storage__FFI.urs and the type [storage]) > > > On Sun, May 21, 2017 at 8:10 PM, Artyom Shalkhakov > > wrote: > >> > >> 2017-05-22 6:22 GMT+06:00 Aistis Raulinaitis : > >> > 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 > >> > > >> > > >> > ~~~ > >> > 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 > >> > > >> > >> I got the impression that Ur/Web being a whole-program optimizing > >> compiler, the only types being supported for marshalling between FFI > >> code and non-FFI code are primitive types and abstract types. I think > >> I asked this same question some time ago. > >> > >> So it looks like you will have to work around this somehow. > >> > >> > > >> > > >> > ___ > >> > Ur mailing list > >> > Ur@impredicative.com > >> > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > >> > > >> > >> > >> > >> -- > >> Cheers, > >> Artyom Shalkhakov > >> > >> ___ > >> Ur mailing list > >> Ur@impredicative.com > >> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > > > > > > > > ___ > > Ur mailing list > > Ur@impredicative.com > > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > > > > > > -- > Cheers, > Artyom Shalkhakov > > ___ > Ur mailing list > Ur@impredicative.com > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] About clientOnly
Hmm, remodeling it to be similar to the examples you gave doesn't seem to help. I noticed that none of the types in those examples take type parameters, maybe that has something to do with the difficulties I'm facing? On Sun, May 21, 2017 at 8:31 PM, Aistis Raulinaitis wrote: > Thanks! > > On Sun, May 21, 2017 at 8:27 PM, Artyom Shalkhakov < > artyom.shalkha...@gmail.com> wrote: > >> 2017-05-22 9:19 GMT+06:00 Aistis Raulinaitis : >> > 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.. >> > >> >> Sure, here are two examples: >> >> https://github.com/bbarenblat/urweb-regex (in particular, take a look >> at regex__FFI.urs and the two types [substring_t] and >> [substring_list_t]) >> https://github.com/ashalkhakov/urweb-storage (shameless plug; in >> particular, take a look at storage__FFI.urs and the type [storage]) >> >> > On Sun, May 21, 2017 at 8:10 PM, Artyom Shalkhakov >> > wrote: >> >> >> >> 2017-05-22 6:22 GMT+06:00 Aistis Raulinaitis : >> >> > 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 >> >> > >> >> > >> >> > ~~~ >> >> > 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 >> >> > >> >> >> >> I got the impression that Ur/Web being a whole-program optimizing >> >> compiler, the only types being supported for marshalling between FFI >> >> code and non-FFI code are primitive types and abstract types. I think >> >> I asked this same question some time ago. >> >> >> >> So it looks like you will have to work around this somehow. >> >> >> >> > >> >> > >> >> > ___ >> >> > Ur mailing list >> >> > Ur@impredicative.com >> >> > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >> >> > >> >> >> >> >> >> >> >> -- >> >> Cheers, >> >> Artyom Shalkhakov >> >> >> >> ___ >> >> Ur mailing list >> >> Ur@impredicative.com >> >> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >> > >> > >> > >> > ___ >> > Ur mailing list >> > Ur@impredicative.com >> > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >> > >> >> >> >> -- >> Cheers, >> Artyom Shalkhakov >> >> ___ >> Ur mailing list >> Ur@impredicative.com >> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >> > > ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] About clientOnly
Ah, if I remove the type variables from the FFI urs and keep some phantom type variables in the wrapper urs, it seems to work! Thanks! On Sun, May 21, 2017 at 8:27 PM, Artyom Shalkhakov < artyom.shalkha...@gmail.com> wrote: > 2017-05-22 9:19 GMT+06:00 Aistis Raulinaitis : > > 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.. > > > > Sure, here are two examples: > > https://github.com/bbarenblat/urweb-regex (in particular, take a look > at regex__FFI.urs and the two types [substring_t] and > [substring_list_t]) > https://github.com/ashalkhakov/urweb-storage (shameless plug; in > particular, take a look at storage__FFI.urs and the type [storage]) > > > On Sun, May 21, 2017 at 8:10 PM, Artyom Shalkhakov > > wrote: > >> > >> 2017-05-22 6:22 GMT+06:00 Aistis Raulinaitis : > >> > 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 > >> > > >> > > >> > ~~~ > >> > 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 > >> > > >> > >> I got the impression that Ur/Web being a whole-program optimizing > >> compiler, the only types being supported for marshalling between FFI > >> code and non-FFI code are primitive types and abstract types. I think > >> I asked this same question some time ago. > >> > >> So it looks like you will have to work around this somehow. > >> > >> > > >> > > >> > ___ > >> > Ur mailing list > >> > Ur@impredicative.com > >> > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > >> > > >> > >> > >> > >> -- > >> Cheers, > >> Artyom Shalkhakov > >> > >> ___ > >> Ur mailing list > >> Ur@impredicative.com > >> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > > > > > > > > ___ > > Ur mailing list > > Ur@impredicative.com > > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > > > > > > -- > Cheers, > Artyom Shalkhakov > > ___ > Ur mailing list > Ur@impredicative.com > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur