annotate tests/list.ur @ 758:8323c1beef2e
Subforms type-checks; lists urlified and unurlified
author |
Adam Chlipala <adamc@hcoop.net> |
date |
Thu, 30 Apr 2009 11:48:56 -0400 |
parents |
fa2019a63ea4 |
children |
9021d44ba6b2 |
rev |
line source |
adamc@757
|
1 fun isNil (t ::: Type) (ls : list t) =
|
adamc@757
|
2 case ls of
|
adamc@757
|
3 Nil => True
|
adamc@757
|
4 | _ => False
|
adamc@196
|
5
|
adamc@757
|
6 fun delist (ls : list string) : xbody =
|
adamc@757
|
7 case ls of
|
adamc@757
|
8 Nil => <xml>Nil</xml>
|
adamc@757
|
9 | Cons (h, t) => <xml>{[h]} :: {delist t}</xml>
|
adamc@196
|
10
|
adamc@758
|
11 fun callback ls = return <xml><body>
|
adamc@758
|
12 {delist ls}
|
adamc@758
|
13 </body></xml>
|
adamc@758
|
14
|
adamc@757
|
15 fun main () = return <xml><body>
|
adamc@757
|
16 {[isNil (Nil : list bool)]},
|
adamc@757
|
17 {[isNil (Cons (1, Nil))]},
|
adamc@757
|
18 {[isNil (Cons ("A", Cons ("B", Nil)))]}
|
adamc@196
|
19
|
adamc@757
|
20 <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p>
|
adamc@758
|
21 <a link={callback (Cons ("A", Cons ("B", Nil)))}>Go!</a>
|
adamc@757
|
22 </body></xml>
|