
20 Nov
2009
20 Nov
'09
3:08 p.m.
You know, another solution to the records problem, which is not quite as convenient but much simpler (and has other applications) is to allow local modules.
module Foo where module Bar where data Bar = Bar { x :: Int, y :: Int } module Baz where data Baz = Baz { x :: Int, y :: Int }
f a b = Bar.x a + Baz.y b
For someone coming from an SML background, that makes a lot of sense. You could also add an "automatic lightweight module", like Agda does, where data Baz = Node { x :: Int, y :: Int } implicitly defines a local module Baz with record selection functions Baz.x and Baz.y and even a Baz.Node constructor. Stefan