# HG changeset patch # User Adam Chlipala # Date 1224631871 14400 # Node ID df4cbd90a26ed094fe76f5f5a57e84a24ddc5fef # Parent 06fcddcd20d3c9b8bc9461b0d4565a84e467c18a Infering sum rows diff -r 06fcddcd20d3 -r df4cbd90a26e demo/sum.ur --- a/demo/sum.ur Tue Oct 21 19:24:39 2008 -0400 +++ b/demo/sum.ur Tue Oct 21 19:31:11 2008 -0400 @@ -1,9 +1,9 @@ -fun sum (fs :: {Unit}) (x : $(mapUT int fs)) = +fun sum (fs ::: {Unit}) (x : $(mapUT int fs)) = foldUR [int] [fn _ => int] (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] n acc => n + acc) 0 [fs] x fun main () = return - {[sum [[A, B]] {A = 0, B = 1}]}
- {[sum [[C, D, E]] {C = 2, D = 3, E = 4}]} + {[sum {A = 0, B = 1}]}
+ {[sum {C = 2, D = 3, E = 4}]}
diff -r 06fcddcd20d3 -r df4cbd90a26e lib/top.ur --- a/lib/top.ur Tue Oct 21 19:24:39 2008 -0400 +++ b/lib/top.ur Tue Oct 21 19:31:11 2008 -0400 @@ -31,8 +31,8 @@ tf -> tr rest -> tr ([nm] ++ rest)) (i : tr []) = fold [fn r :: {Unit} => $(mapUT tf r) -> tr r] - (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) (acc : $(mapUT tf rest) -> tr rest) - [[nm] ~ rest] (r : $([nm = tf] ++ mapUT tf rest)) => + (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc + [[nm] ~ rest] r => f [nm] [rest] r.nm (acc (r -- nm))) (fn _ => i) diff -r 06fcddcd20d3 -r df4cbd90a26e src/elaborate.sml --- a/src/elaborate.sml Tue Oct 21 19:24:39 2008 -0400 +++ b/src/elaborate.sml Tue Oct 21 19:31:11 2008 -0400 @@ -1,4 +1,4 @@ - (* Copyright (c) 2008, Adam Chlipala +(* Copyright (c) 2008, Adam Chlipala * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -743,7 +743,10 @@ fun unfold (dom, ran, f, i, r, c) = let val nm = cunif (loc, (L'.KName, loc)) - val v = cunif (loc, dom) + val v = + case dom of + (L'.KUnit, _) => (L'.CUnit, loc) + | _ => cunif (loc, dom) val rest = cunif (loc, (L'.KRecord dom, loc)) val acc = (L'.CFold (dom, ran), loc) val acc = (L'.CApp (acc, f), loc)