Mercurial > urweb
comparison tests/stuff.lac @ 12:d89477f07c1e
Fun with records
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Fri, 28 Mar 2008 17:34:57 -0400 |
parents | e97c6d335869 |
children |
comparison
equal
deleted
inserted
replaced
11:e97c6d335869 | 12:d89477f07c1e |
---|---|
14 con c9 = {} | 14 con c9 = {} |
15 con c10 = ([]) :: {Type} | 15 con c10 = ([]) :: {Type} |
16 | 16 |
17 val v1 = fn t :: Type => fn x : t => x | 17 val v1 = fn t :: Type => fn x : t => x |
18 val v2 = v1 [t :: Type -> t -> t] v1 | 18 val v2 = v1 [t :: Type -> t -> t] v1 |
19 | |
20 val r = {X = v1, Y = v2} | |
21 val v1_again = r.X | |
22 val v2_again = r.Y | |
23 | |
24 val r2 = {X = {}, Y = v2, Z = {}} | |
25 val r2_X = r2.X | |
26 val r2_Y = r2.Y | |
27 val r2_Z = r2.Z | |
28 | |
29 val f = fn fs :: {Type} => fn x : $([X = {}] ++ fs) => x.X | |
30 val f2 = fn fs :: {Type} => fn x : $(fs ++ [X = {}]) => x.X | |
31 val f3 = fn fs :: {Type} => fn x : $([X = {}, Y = {Z : {}}] ++ fs) => x.X | |
32 val f4 = fn fs :: {Type} => fn x : $([X = {}, Y = {Z : {}}] ++ fs) => x.Y | |
33 val f5 = fn fs1 :: {Type} => fn fs2 :: {Type} => fn x : $(fs1 ++ [X = {}] ++ fs2) => x.X | |
34 val f6 = fn fs1 :: {Type} => fn fs2 :: {Type} => fn x : $(fs1 ++ [X = {}] ++ fs2 ++ [Y = {Z : {}}]) => x.X | |
35 val f7 = fn fs1 :: {Type} => fn fs2 :: {Type} => fn x : $(fs1 ++ [X = {}] ++ fs2 ++ [Y = {Z : {}}]) => x.Y | |
36 | |
37 val test = f [[Y = t :: Type -> t -> t, Z = {}]] r2 | |
38 val test = f7 [[Y = t :: Type -> t -> t]] [[Z = {}]] r2 |