[Ur] typechecker rejects form handler
Sergey Mironov
grrwlf at gmail.com
Sat Jan 4 13:02:30 EST 2014
Hi. Could you please take a look at the program. Looks like
typechecker is wrong here. Full program is in attach, the faulty code
is below.
Thanks in advance,
Sergey
--
Faulty form handler:
fun form (sd:string) (fview : int -> url) (ferr : string -> url) :
transaction xbody =
let
fun retry {} : transaction page =
redirect (ferr "Invalid form value")
fun handler (s:{Text:string}) : transaction page =
i <- nextval adv_s;
dml(INSERT INTO adv (Id, Text) VALUES ({[i]}, {[s.Text]}));
redirect (fview i)
fun validator (s:{Text:string}) : transaction page =
case s.Text != "" of
True => handler s
| False => retry {}
(* Note: looks like it is the case expression who causes troubles.
Without it code works:
fun validator (s:{Text:string}) : transaction page =
handler s
*)
in
return
<xml>
<form>
<textarea{#Text}>
{[sd]}
</textarea>
<br/>
<submit action={validator}/>
</form>
</xml>
end
The error message is
$ urweb -dbms sqlite FormBug
FormBug.ur:48:11: (to 48:17) Unification failure
Expression: s.#Text
Have con: string
Need con:
[<UNIF:U292::{<UNIF:U>}> ~ <UNIF:U293::{<UNIF:V>}>] =>
<UNIF:U294::Type>
Incompatible constructors
Have: string
Need:
[<UNIF:U292::{<UNIF:U>}> ~ <UNIF:U293::{<UNIF:V>}>] =>
<UNIF:U294::Type>
Note, I am still using pre-released version of urweb, but I suppose it
doesn't meter here.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FormBug.ur
Type: application/octet-stream
Size: 2097 bytes
Desc: not available
URL: <http://www.impredicative.com/pipermail/ur/attachments/20140104/04ff2ee6/attachment.obj>
More information about the Ur
mailing list