view tests/option.ur @ 1908:ab1a3737b306

make clean: Clean bin/mlton, src/urweb.mlton.lex, src/urweb.mlton.grm Signed-off-by: Anders Kaseorg <andersk@mit.edu> --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
author Anders Kaseorg <andersk@mit.edu>
date Fri, 22 Nov 2013 09:36:14 -0500
parents 77a28e7430bf
children
line wrap: on
line source
datatype option a = None | Some of a

val none_Hi : option string = None
val some_Hi = Some "Hi"
val none_some_Hi : option (option string) = None
val some_some_Hi = Some some_Hi

val show = fn x => case x of None => "None" | Some x => x

val show2 = fn x => case x of None => "None'" | Some x => show x

val page = fn x => return <html><body>
        {cdata (show x)}
</body></html>

val page2 = fn x => return <html><body>
        {cdata (show2 x)}
</body></html>

val main : unit -> transaction page = fn () => return <html><body>
        <li><a link={page none_Hi}>None1</a></li>
        <li><a link={page some_Hi}>Some1</a></li>
        <li><a link={page2 none_some_Hi}>None2</a></li>
        <li><a link={page2 some_some_Hi}>Some2</a></li>
</body></html>