To my recent suggestion on the field label overloading
... data Foo1 = Foo1 {size :: Int ...} data Foo2 = Foo2 {size :: Int ...} ... f x y z = let size = Foo1..size in (size x)+(size y)+(Foo2..size z)
Hal Daume III wrote on Jan 13, 2004
How does this save you typing over:
data Foo1 = Foo1 { foo1_size :: Int } data Foo2 = Foo2 { foo2_size :: Int }
f x y z = let size = foo1_size in (size x) + (size y) + (Foo2..size z)
also, this would lead to highly ambiguous parses, i think.
Here is an example with improved suggestion: data Foo1 = Foo1 {size :: Int, ...} data Foo2 = Foo2 {size :: Int, ...} data Foo3 a b = Foo3 {size :: a, ...} f :: Foo1 -> Foo1 -> Foo2 -> Int f x y z = let n = (size x)+(size y)+(size z) in (g (x {size = n})) + 1 h v = v {size = 0} :: Foo3 _ _ g u = size (u :: Foo3 _ _) Very often the type or argument is clear. In such a case the compiler solves the label version. And in a dubious case the programmer adds the type denotation. Will this do? Copy, please, the answer to mechvel@botik.ru With kind regards, ----------------- Serge Mechveliani mechvel@botik.ru