summaryrefslogtreecommitdiff
path: root/tests/list.ur
blob: 480bdd3e5134e20ca6179c334d22efab2f256ecb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fun isNil (t ::: Type) (ls : list t) =
    case ls of
        Nil => True
      | _ => False

fun delist (ls : list string) : xbody =
        case ls of
            Nil => <xml>Nil</xml>
          | Cons (h, t) => <xml>{[h]} :: {delist t}</xml>

fun callback ls = return <xml><body>
  {delist ls}
</body></xml>

fun main () = return <xml><body>
  {[isNil (Nil : list bool)]},
  {[isNil (Cons (1, Nil))]},
  {[isNil (Cons ("A", Cons ("B", Nil)))]}

  <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p>
  <a link={callback (Cons ("A", Cons ("B", Nil)))}>Go!</a>
</body></xml>