[Ur] Compilation error using onchange with ccheckbox
Sergey Mironov
grrwlf at gmail.com
Sat Jul 25 02:31:29 EDT 2015
You may check the type signatures by consulting basis.urs from the
Ur/Web's repo. Among other 'built-in' declarations, we may find there
val ccheckbox : cformTag ([Value = bool, Size = int, Source = source
bool, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
... Onchange = transaction unit ...
That is how Juian may 'know in advance' the correct style :)
Regards,
Sergey
2015-07-24 15:30 GMT+03:00 Julian Squires <julian at cipht.net>:
> On Fri, Jul 24, 2015 at 7:49 AM, Graham Hopper
> <graham at garden-images.co.uk> wrote:
>> <ccheckbox onchange={fn _ => alert "Changed!"}/>
>
> Try
> <ccheckbox onchange={alert "Changed!"} />
>
>> The error is long winded but I think the important part is:
>>
>> Need:
>> <UNIF:U52::{Type}> ++ [Onchange = <UNIF:U69::Type> -> transaction {}]
>> Field: #Onchange
>> Value 1: transaction {}
>> Value 2: <UNIF:U69::Type> -> transaction {}
>> Incompatible constructors
>> Have: transaction {}
>> Need: <UNIF:U69::Type> -> transaction {}
>
> Onchange has the signature transaction unit, where as you might have
> expected it to be like the mouse events (onclick, et cetera) which
> have signature mouseEvent -> transaction unit, which is why they are
> typically written with an anonymous function that discards its
> arguments as you did above.
>
> Hope this helps,
>
> --
> Julian Squires
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
More information about the Ur
mailing list