summaryrefslogtreecommitdiff
path: root/tests/specialize.ur
blob: eba7c616752df07c3c1fd955edbf5213f423a59b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
datatype list a = Nil | Cons of a * list a

fun isNil (t ::: Type) (ls : list t) : bool =
        case ls of
          Nil => True
        | Cons _ => False

fun append (t ::: Type) (ls1 : list t) (ls2 : list t) : list t =
        case ls1 of
          Nil => ls2
        | Cons (x, ls1') => Cons (x, append ls1' ls2)

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

val ls = Cons ("X", Cons ("Y", Cons ("Z", Nil)))
val ls' = Cons ("A", Cons ("B", Nil))

fun main () : transaction page = return <html><body>
        {if isNil ls then <body>It's Nil.</body> else <body>It's not Nil.</body>}

        <p>{delist (append ls' ls)}</p>
</body></html>