annotate tests/nest.ur @ 1222:117f13bdc1fd

Express all query outputs using record literals
author Adam Chlipala <adamc@hcoop.net>
date Sun, 11 Apr 2010 12:45:15 -0400
parents 787d4931fb07
children
rev   line source
adamc@448 1 fun add x =
adamc@448 2 let
adamc@448 3 fun add' y = x + y
adamc@448 4 in
adamc@448 5 add' 1 + add' 2
adamc@448 6 end
adamc@448 7
adamc@448 8 fun f (x : int) =
adamc@448 9 let
adamc@448 10 fun page () = return <xml><body>
adamc@448 11 <a link={page ()}>{[x]}</a>
adamc@448 12 </body></xml>
adamc@448 13 in
adamc@448 14 page
adamc@448 15 end
adamc@448 16
adamc@448 17 fun f (x : int) =
adamc@448 18 let
adamc@448 19 fun page1 () = return <xml><body>
adamc@448 20 <a link={page2 ()}>{[x]}</a>
adamc@448 21 </body></xml>
adamc@448 22
adamc@448 23 and page2 () =
adamc@448 24 case Some True of
adamc@448 25 Some r => return <xml><body><a link={page1 ()}>{[r]}</a></body></xml>
adamc@448 26 | _ => return <xml>Error</xml>
adamc@448 27 in
adamc@450 28 page2
adamc@450 29 end
adamc@450 30
adamc@450 31 fun f (x : int) =
adamc@450 32 let
adamc@450 33 fun page1 () = return <xml><body>
adamc@450 34 <a link={page2 ()}>{[x]}</a>
adamc@450 35 </body></xml>
adamc@450 36
adamc@450 37 and page2 () =
adamc@450 38 case Some True of
adamc@450 39 Some r => return <xml><body><a link={page1 ()}>{[r]}</a></body></xml>
adamc@450 40 | _ => return <xml><body><a link={page3 ()}>!!</a></body></xml>
adamc@450 41
adamc@450 42 and page3 () = return <xml><body><a link={page2 ()}>!</a><a link={page1 ()}>!</a>
adamc@450 43 <a link={page3 ()}>!</a></body></xml>
adamc@450 44 in
adamc@450 45 page3
adamc@448 46 end
adamc@448 47
adamc@453 48 fun add2 (x : int) (y : int) =
adamc@453 49 let
adamc@453 50 fun add3 () = x + y
adamc@453 51 in
adamc@453 52 add3
adamc@453 53 end
adamc@453 54
adamc@453 55 fun add3 (x : int) =
adamc@453 56 let
adamc@453 57 fun add2 (y : int) =
adamc@453 58 let
adamc@453 59 fun add1 (z : int) = x + y + z
adamc@453 60 in
adamc@453 61 add1
adamc@453 62 end
adamc@453 63 in
adamc@453 64 add2
adamc@453 65 end
adamc@453 66
adamc@453 67 (*datatype list t = Nil | Cons of t * list t
adamc@448 68
adamc@448 69 fun length (t ::: Type) (ls : list t) =
adamc@448 70 let
adamc@448 71 fun length' ls acc =
adamc@448 72 case ls of
adamc@448 73 Nil => acc
adamc@448 74 | Cons (_, ls') => length' ls' (acc + 1)
adamc@448 75 in
adamc@448 76 length' ls 0
adamc@448 77 end
adamc@450 78
adamc@453 79 *)