summaryrefslogtreecommitdiff
path: root/tests/nest.ur
blob: 8da507125cd96cc04b462ab71e17f27028ec1548 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
fun add x =
    let
        fun add' y = x + y
    in
        add' 1 + add' 2
    end

fun f (x : int) =
    let
        fun page () = return <xml><body>
          <a link={page ()}>{[x]}</a>
        </body></xml>
    in
        page
    end

fun f (x : int) =
    let
        fun page1 () = return <xml><body>
          <a link={page2 ()}>{[x]}</a>
        </body></xml>

        and page2 () =
            case Some True of
                Some r => return <xml><body><a link={page1 ()}>{[r]}</a></body></xml>
              | _ => return <xml>Error</xml>
    in
        page2
    end

fun f (x : int) =
    let
        fun page1 () = return <xml><body>
          <a link={page2 ()}>{[x]}</a>
        </body></xml>

        and page2 () =
            case Some True of
                Some r => return <xml><body><a link={page1 ()}>{[r]}</a></body></xml>
              | _ => return <xml><body><a link={page3 ()}>!!</a></body></xml>

        and page3 () = return <xml><body><a link={page2 ()}>!</a><a link={page1 ()}>!</a>
          <a link={page3 ()}>!</a></body></xml>
    in
        page3
    end

datatype list t = Nil | Cons of t * list t

fun length (t ::: Type) (ls : list t) =
    let
        fun length' ls acc =
            case ls of
                Nil => acc
              | Cons (_, ls') => length' ls' (acc + 1)
    in
        length' ls 0
    end