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.
FormBug.ur
Description: Binary data
_______________________________________________ Ur mailing list [email protected] http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
