annotate tests/nest.ur @ 452:222cbc1da232

Fix some type-class detection
author Adam Chlipala <adamc@hcoop.net>
date Sat, 01 Nov 2008 17:19:12 -0400
parents 07f6576aeb0a
children 787d4931fb07
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@448 48 datatype list t = Nil | Cons of t * list t
adamc@448 49
adamc@448 50 fun length (t ::: Type) (ls : list t) =
adamc@448 51 let
adamc@448 52 fun length' ls acc =
adamc@448 53 case ls of
adamc@448 54 Nil => acc
adamc@448 55 | Cons (_, ls') => length' ls' (acc + 1)
adamc@448 56 in
adamc@448 57 length' ls 0
adamc@448 58 end
adamc@450 59