I\'m using lots of different records in a program, with some of them using the same field names, e.g.
data Customer = Customer { ..., foo :: Int, ... }
data
There's a language extension DuplicateRecordFields that allows duplication of field functions and makes its type to be inferred by type annotation.
Here is a little example (haskell-stack script):
#!/usr/bin/env stack
-- stack runghc --resolver lts-8.20 --install-ghc
{-# LANGUAGE DuplicateRecordFields #-}
newtype Foo = Foo { baz :: String }
newtype Bar = Bar { baz :: String }
foo = Foo { baz = "foo text" }
bar = Bar { baz = "bar text" }
main = do
putStrLn $ "Foo: " ++ baz (foo :: Foo) -- Foo: foo text
putStrLn $ "Bar: " ++ baz (bar :: Bar) -- Bar: bar text