
On 2009 Apr 7, at 9:00, John Dorsey wrote:
I've noticed that if I declare two types like this
data Thing1 = Thing1 { itemPos :: Int } data Thing2 = Thing2 { itemPos :: Int }
then I get the error "Multiple declarations of Main.itemPos"
Here's something to consider. What's the type of itemPos? In the above code, it can't be
itemPos :: Thing1 -> Int
because you want to be able to apply it to a Thing2. I suppose the compiler could, behind the scenes, create a typeclass like this:
I think it already does this if you ask for the DisambiguateRecordFields language extension (provided it can tell which one is needed!).
For that matter, I don't know what the term is for a "StaffItem-type LayoutItem". The type is clearly LayoutItem. "StaffItem" is the constructor. How do you refer to the concept of a LayoutItem constructed via a StaffItem?
You can just call it "a StaffItem", I guess. I don't know if there's a common term. But you're right that it's type is LayoutItem.
Technically LayoutItem is a sum of products and StaffItem is a variant (see http://en.wikipedia.org/wiki/Sum_type for more information). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH