Mercurial > urweb
annotate tests/list.ur @ 266:7a7efbb3e354
Monoize aggregates
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 31 Aug 2008 16:26:50 -0400 |
parents | 71bafe66dbe1 |
children | fa2019a63ea4 |
rev | line source |
---|---|
adamc@196 | 1 datatype list a = Nil | Cons of a * list a |
adamc@196 | 2 |
adamc@196 | 3 val isNil = fn t ::: Type => fn ls : list t => |
adamc@196 | 4 case ls of Nil => True | _ => False |
adamc@196 | 5 |
adamc@196 | 6 val show = fn b => if b then "True" else "False" |
adamc@196 | 7 |
adamc@196 | 8 val rec delist : list string -> xml body [] [] = fn x => |
adamc@196 | 9 case x of |
adamc@196 | 10 Nil => <body>Nil</body> |
adamc@196 | 11 | Cons (h, t) => <body>{cdata h} :: {delist t}</body> |
adamc@196 | 12 |
adamc@196 | 13 val main : unit -> page = fn () => <html><body> |
adamc@196 | 14 {cdata (show (isNil (Nil : list bool)))}, |
adamc@196 | 15 {cdata (show (isNil (Cons (1, Nil))))}, |
adamc@196 | 16 {cdata (show (isNil (Cons ("A", Cons ("B", Nil)))))} |
adamc@196 | 17 |
adamc@196 | 18 <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p> |
adamc@196 | 19 </body></html> |