[Ur] Type signature for a form handler
mutaamba maasha
maasha at gmail.com
Fri Oct 3 23:54:51 EDT 2014
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
(* The answer to the your question is :
val login : { Username : string , Password : string } ->
transaction page
The module gives a sample implementation and
signature.
Besides their usage in forms they I records helpful
when defining a function with multiple arguments for
example:
and post' (title : string)
(body : string)
(username : string)
(created : time) : xbody = ...
would be:
post' ( p : { Title : string
, Body : string
, Username : string
, Create : time }) : xbody = ...
So for function calls with many arguments I know what each
parameter is being used for.
e.g.
(fn row => post' { Title = "tofu is so great"
, Body = <xml>...</xml>
, Username = row.Users.Username
, Create = row.Posts.Created})
It is a trivial example but you can imagine more elaborate
scenarios.
I digress, hopeful my meandering is of some help and I have
answered your question. Below is sample implementation.
Happy hacking
*)
signature AUTH = sig
val login : { Username : string , Password : string } ->
transaction page
end
structure Auth : AUTH = struct
fun login (r : { Username : string , Password : string }) :
transaction page =
return
<xml>
<head><title>welcome to tofu palace</title></head>
<body>
<p>Username:{[r.Username]}</p>
<p>Password:{[r.Password]}</p>
</body>
</xml>
end
fun login_form () : transaction page =
return
<xml>
<head><title>welcome to tofu palace</title></head>
<body>
<form>
Username:<textbox{#Username}/>
Password:<password{#Password}/>
<submit value="Login" action={Auth.login}/>
</form>
</body>
</xml>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBAgAGBQJUL2+LAAoJEHxRxnzR1VWy35gP/izXyoPE9nF2UyBezEyVZq3M
IlAMNuiqeEBLrvy34EozXj4LgWZnpFzIRKtdDAvhYKYDY4KeCVk3FSDAkR5g/iZl
3FcVwa8e4w8jPv9mq3YgAk3j+lRlE6qFpOFtcfLaf+5lVNYzXmingqUubWh9v/vp
04kMb689B4rXF2PDZ7xEI29XNOKSL7pPj/ZIQtsyhTHYtSjuk/NktQM5bkgRskps
W654tDkaD8a8TNDPHyu07RcuczK/5OKHplOpcSJEbolP3X75lNM0UrlU86nTKqnV
1eIMjPjLMoVZ4HiVBt1bUDSc3pib5ithSjk5zzcQSyVP7a6fdAhQBgm2/z9LriZh
5djqe7gegZ7B0KAFYP6skVTH7+hsyNzFCxF5zub3ymKlor0oE8Qyrr+sWNlmIINj
1XN4c//lLVVNarZUY7vwaHwDlo94n43btHBUysPV4G/aOEu0BVeVzSoG4f7i8S6P
8vPG3Pzi09iRdqGa4BEgq4Kjb3EP52f1NWfFcYfcXxM67hAGrP4K0IPaO3FII/ry
UPCBWw9L33qpmAVAdZjNxUQT/vs+1vMHqRaJtdLf3glFYN1nAbprVoE8RZZbOsCW
HbagTj2vtpJFChWs3KuAbR9/weSNV4XC63vP9SRKcfCHqElv5nIXyejfQfX5BL4c
iFUlrExHlo9TRgYyGz+D
=uRh+
-----END PGP SIGNATURE-----
More information about the Ur
mailing list