diff options
-rw-r--r-- | src/reduce.sml | 6 | ||||
-rw-r--r-- | tests/reduce.lac | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/reduce.sml b/src/reduce.sml index 7a5b7367..fd2d5b1a 100644 --- a/src/reduce.sml +++ b/src/reduce.sml @@ -144,6 +144,12 @@ fun exp env e = | ECApp ((ECAbs (_, _, e1), loc), c) => #1 (reduceExp env (subConInExp (0, c) e1)) + | EField ((ERecord xes, _), (CName x, _), _) => + (case List.find (fn ((CName x', _), _) => x' = x + | _ => false) xes of + SOME (_, e) => #1 e + | NONE => e) + | _ => e and reduceExp env = U.Exp.mapB {kind = kind, con = con, exp = exp, bind = bind} env diff --git a/tests/reduce.lac b/tests/reduce.lac index 2585862d..9cdc2a1a 100644 --- a/tests/reduce.lac +++ b/tests/reduce.lac @@ -14,7 +14,12 @@ con apply = fn f :: Type -> Type => fn t :: Type => f t con c6 = apply id int con c7 = apply (fst int) string -val grab = fn n :: Name => fn t :: Type => fn fs :: {Type} => +val tickle = fn n :: Name => fn t :: Type => fn fs :: {Type} => fn x : $([n = t] ++ fs) => x -val grabA = grab[#A][int][[B = string]] -val test_grabA = grabA {A = 6, B = "13"} +val tickleA = tickle[#A][int][[B = string]] +val test_tickleA = tickleA {A = 6, B = "13"} + +val grab = fn n :: Name => fn t ::: Type => fn fs ::: {Type} => + fn x : $([n = t] ++ fs) => x.n +val test_grab1 = grab[#A] {A = 6, B = "13"} +val test_grab2 = grab[#B] {A = 6, B = "13"} |