comparison tests/specialize.ur @ 316:04ebfe929a98

Unpolyed a polymorphic function of two arguments
author Adam Chlipala <adamc@hcoop.net>
date Thu, 11 Sep 2008 10:14:59 -0400
parents e21d0dddda09
children 6a4e365db60c
comparison
equal deleted inserted replaced
315:e21d0dddda09 316:04ebfe929a98
3 fun isNil (t ::: Type) (ls : list t) : bool = 3 fun isNil (t ::: Type) (ls : list t) : bool =
4 case ls of 4 case ls of
5 Nil => True 5 Nil => True
6 | Cons _ => False 6 | Cons _ => False
7 7
8 (*fun append (t ::: Type) (ls1 : list t) (ls2 : list t) : list t = 8 fun append (t ::: Type) (ls1 : list t) (ls2 : list t) : list t =
9 case ls1 of 9 case ls1 of
10 Nil => ls2 10 Nil => ls2
11 | Cons (x, ls1') => Cons (x, append ls1' ls2) 11 | Cons (x, ls1') => Cons (x, append ls1' ls2)
12 12
13 fun delist (ls : list string) : xml body [] [] = 13 fun delist (ls : list string) : xml body [] [] =
14 case ls of 14 case ls of
15 Nil => <body>Nil</body> 15 Nil => <body>Nil</body>
16 | Cons (h, t) => <body>{cdata h} :: {delist t}</body>*) 16 | Cons (h, t) => <body>{cdata h} :: {delist t}</body>
17 17
18 val ls = Cons ("X", Cons ("Y", Cons ("Z", Nil))) 18 val ls = Cons ("X", Cons ("Y", Cons ("Z", Nil)))
19 val ls' = Cons ("A", Cons ("B", Nil))
19 20
20 fun main () : transaction page = return <html><body> 21 fun main () : transaction page = return <html><body>
21 {if isNil ls then <body>It's Nil.</body> else <body>It's not Nil.</body>} 22 {if isNil ls then <body>It's Nil.</body> else <body>It's not Nil.</body>}
23
24 <p>{delist (append ls' ls)}</p>
22 </body></html> 25 </body></html>
23 26
24 27
25 (* <p>{delist ls}</p>*)
26 28
29