[Ur] UR/Web SVG (ffi) question
Dear all, I am a novice with respect to UR/Web and I want to use it together with SVG. I found the prototype ffi for SVG at https://github.com/karsar/urweb-examples/tree/master/SVGTest after reading through the material, doing all the tutorials and generally digging around internet. Anyway, I took the example from https://github.com/karsar/urweb-examples/tree/master/SVGTest and tried to modify it; I fail repeatedly, so now I turn to this email list. Instead of the SVGTest.ur that has all the functionality in main, I tried to break it out to a separate function "proc". I took the idea from http://www.impredicative.com/ur/demo/sql.html to generate an html page into a variable and then add that as return statement in the main function as seen below. = Modified SVGTest.ur with respect to https://github.com/karsar/urweb-examples/tree/master/SVGTest open SVG con intPair = int*int fun fst (x: intPair) = x.1 fun snd (x: intPair) = x.2 fun circleDraw(x: intPair): xsvg = fun proc (x: intPair) = x <- source x; return set x (ev.ScreenX,ev.SceenY)}> {circleDraw x} }/> fun main(): transaction page = xml <- proc (0,0); return Banzai {xml} I have tried different options (e.g., that the proc should return transaction page, xbody, xsvg) and I fail in different ways. (I tried to add other functionality initially, but I removed it to try to get to the bottom of the problem). The compiler tells me: urweb SVGTest /home/a/SVGTest2/SVGTest.ur:33:4: (to 44:2) Error in final record unification Can't unify record constructors Have: [Dyn = (), MakeForm = (), Body = ()] Need: [Html = ()] /home/a/SVGTest2/SVGTest.ur:33:4: (to 44:2) Stuck unifying these records after canceling matching pieces: Have: [Dyn = (), MakeForm = (), Body = ()] Need: [Html = ()] /home/a/SVGTest2/SVGTest.ur:17:7: (to 17:64) Error in final record unification Can't unify record constructors Have: [Data = data_attr, Onload = transaction {}, Onresize = transaction {}, Onunload = transaction {}, Onhashchange = transaction {}, [<<< REMOVED to reduce size of message>>>] Value 1: {ScreenX : int, ScreenY : int, ClientX : int, ClientY : int, CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool, Button : mouseButton} -> transaction {} Value 2: $(([ScreenX = int, SceenY = int]) ++ ) -> transaction {} Can't unify record constructors Have: [ScreenX = int, ScreenY = int, ClientX = int, ClientY = int, CtrlKey = bool, ShiftKey = bool, AltKey = bool, MetaKey = bool, Button = mouseButton] Need: ++ [ScreenX = int, SceenY = int] Compilation exited abnormally with code 1 at Wed Apr 11 08:45:06 Thanks in advance, Jonas Mellin, Senior Lecturer, University of Skövde ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] UR/Web SVG (ffi) question
I have not read all of your code, but I did spot the problem behind the first compiler error message, which I think all web developers would agree is problematic. (I.e., it isn't just a question of a fussy Ur/Web type system.) On 04/16/2018 04:58 AM, Jonas Mellin wrote: fun proc (x: intPair) = x <- source x; return set x (ev.ScreenX,ev.SceenY)}> fun main(): transaction page = xml <- proc (0,0); return Banzai {xml} [...] /home/a/SVGTest2/SVGTest.ur:33:4: (to 44:2) Error in final record unification Can't unify record constructors Have: [Dyn = (), MakeForm = (), Body = ()] Need: [Html = ()] Notice that your [proc] code includes a tag, but then you nest it within another tag! ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] UR/Web SVG (ffi) question
Thx. One trial, that I believe should work, is: open SVG (*con intPair = int*int*) fun fst (x: int*int) = x.1 fun snd (x: int*int) = x.2 fun circleDraw(x: int*int): xsvg = fun proc (x: int*int): transaction page = x <- source x; return set x (ev.ScreenX,ev.SceenY)}> {circleDraw x} }/> fun main(): transaction page = let val a = (0,0) in xml <- proc a; return Banzai {xml} end But I get: Can't unify record constructors Have: [ScreenX = int, ScreenY = int, ClientX = int, ClientY = int, CtrlKey = bool, ShiftKey = bool, AltKey = bool, MetaKey = bool, Button = mouseButton] Need: ++ [ScreenX = int, SceenY = int] On " set x (ev.ScreenX,ev.SceenY)}>" From: Ur [mailto:ur-boun...@impredicative.com] On Behalf Of Adam Chlipala Sent: den 16 april 2018 13:29 To: ur@impredicative.com Subject: Re: [Ur] UR/Web SVG (ffi) question I have not read all of your code, but I did spot the problem behind the first compiler error message, which I think all web developers would agree is problematic. (I.e., it isn't just a question of a fussy Ur/Web type system.) On 04/16/2018 04:58 AM, Jonas Mellin wrote: [Jonas Mellin] <<< collapsed answer >>> Notice that your [proc] code includes a tag, but then you nest it within another tag! ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] UR/Web SVG (ffi) question
For future questions, I think it would be good for you to explain what you understand from error messages, highlighting what additional understanding you need to diagnose the error. Here again the problem is a simple one that would be recognized as a bug in any programming language. Notice the difference in spellings of field names, between the "Have" and "Need" parts of the error message. On 04/17/2018 05:53 AM, Jonas Mellin wrote: ... set x (ev.ScreenX,ev.SceenY)}> ... *But I get:*** Can't unify record constructors Have: [ScreenX = int, ScreenY = int, ClientX = int, ClientY = int, CtrlKey = bool, ShiftKey = bool, AltKey = bool, MetaKey = bool, Button = mouseButton] Need: ++ [ScreenX = int, SceenY = int] ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] UR/Web SVG (ffi) question
My bad, sorry. It took me a short while to see the misspelling. Got it working. I will be more careful about that in the future. I move on to trying multiple objects and then adding "foreignObject" tag: val foreignObject : svgTag([X = string, Y = string, Width = string, Height = string] ++ typicalAttrs) an addition to the SVG.urs (cf. original at https://github.com/karsar/urweb-examples/blob/master/SVGTest/SVG.urs) , this require somehow to mix xsvg with xbody. Anything in particular that has to be taken into account when mixing this? /Jonas Mellin From: Ur [mailto:ur-boun...@impredicative.com] On Behalf Of Adam Chlipala Sent: den 17 april 2018 13:20 To: ur@impredicative.com Subject: Re: [Ur] UR/Web SVG (ffi) question For future questions, I think it would be good for you to explain what you understand from error messages, highlighting what additional understanding you need to diagnose the error. Here again the problem is a simple one that would be recognized as a bug in any programming language. Notice the difference in spellings of field names, between the "Have" and "Need" parts of the error message. On 04/17/2018 05:53 AM, Jonas Mellin wrote: ... set x (ev.ScreenX,ev.SceenY)}> ... But I get: Can't unify record constructors Have: [ScreenX = int, ScreenY = int, ClientX = int, ClientY = int, CtrlKey = bool, ShiftKey = bool, AltKey = bool, MetaKey = bool, Button = mouseButton] Need: ++ [ScreenX = int, SceenY = int] ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] UR/Web SVG (ffi) question
I think it should all "just work," with your new tag added in an FFI .urs file like that! On 04/17/2018 08:00 AM, Jonas Mellin wrote: My bad, sorry. It took me a short while to see the misspelling. Got it working. I will be more careful about that in the future. I move on to trying multiple objects and then adding “foreignObject” tag: val foreignObject : svgTag([X = string, Y = string, Width = string, Height = string] ++ typicalAttrs) an addition to the SVG.urs (cf. original at https://github.com/karsar/urweb-examples/blob/master/SVGTest/SVG.urs) , this require somehow to mix xsvg with xbody. Anything in particular that has to be taken into account when mixing this? /Jonas Mellin *From:*Ur [mailto:ur-boun...@impredicative.com] *On Behalf Of *Adam Chlipala *Sent:* den 17 april 2018 13:20 *To:* ur@impredicative.com *Subject:* Re: [Ur] UR/Web SVG (ffi) question For future questions, I think it would be good for you to explain what you understand from error messages, highlighting what additional understanding you need to diagnose the error. Here again the problem is a simple one that would be recognized as a bug in any programming language. Notice the difference in spellings of field names, between the "Have" and "Need" parts of the error message. On 04/17/2018 05:53 AM, Jonas Mellin wrote: ... set x (ev.ScreenX,ev.SceenY)}> ... *But I get:* Can't unify record constructors Have: [ScreenX = int, ScreenY = int, ClientX = int, ClientY = int, CtrlKey = bool, ShiftKey = bool, AltKey = bool, MetaKey = bool, Button = mouseButton] Need: ++ [ScreenX = int, SceenY = int] ___ 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