(FYI, this question is almost certainly a duplicate)
Solutions:
1) Field prefix with a tag indicating the type (extremely common)
data Customer = Customer {..., cFoo :: Int, ...}
2) Use type classes (less common, people complaining about prefixes like cFoo are inconvenient, but obviously not so bad that they will write a class and instance or use TH to do the same).
class getFoo a where foo :: a -> Int instance getFoo Customer where foo = cFoo
3) Use the best field names. If the fields are really different (this is not always the case, my computer has an age, like my employee), then this is the best solution.
Thomas M. DuBuisson Nov 23 '10 at 21:08 2010-11-23 21:08
source share