summaryrefslogtreecommitdiff
path: root/tests/specialize.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-09-11 10:34:47 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-09-11 10:34:47 -0400
commit36e6a1d1da21ec426b2072aae9bb6abf5efa201b (patch)
tree82300d4591c781586a88321c3077210e324cd783 /tests/specialize.ur
parentb404fdb16497e263484383464234f3ddf1d62150 (diff)
Fix memory bounds checks; specialization of multi-argument polymorphic function works
Diffstat (limited to 'tests/specialize.ur')
-rw-r--r--tests/specialize.ur15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/specialize.ur b/tests/specialize.ur
index eba7c616..2c006d1e 100644
--- a/tests/specialize.ur
+++ b/tests/specialize.ur
@@ -10,18 +10,33 @@ fun append (t ::: Type) (ls1 : list t) (ls2 : list t) : list t =
Nil => ls2
| Cons (x, ls1') => Cons (x, append ls1' ls2)
+fun pairAppend (t1 ::: Type) (t2 ::: Type) (ls1 : list (t1 * t2)) (ls2 : list (t1 * t2)) : list (t1 * t2) =
+ case ls1 of
+ Nil => ls2
+ | Cons (x, ls1') => Cons (x, pairAppend 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>
+fun pairDelist (ls : list (string * int)) : xml body [] [] =
+ case ls of
+ Nil => <body>Nil</body>
+ | Cons ((s, n), t) => <body>({cdata s}, {cdata (show _ n)}) :: {pairDelist t}</body>
+
val ls = Cons ("X", Cons ("Y", Cons ("Z", Nil)))
val ls' = Cons ("A", Cons ("B", Nil))
+val pls = Cons (("X", 1), Cons (("Y", 2), Cons (("Z", 3), Nil)))
+val pls' = Cons (("A", 1), Cons (("B", 2), 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>
+
+ <p>{pairDelist (pairAppend pls' pls)}</p>
</body></html>