
On 11 November 2010 13:10, Lauri Alanko
{-# LANGUAGE EmptyDataDecls, MultiParamTypeClasses, FunctionalDependencies #-}
data PetOwner data FurnitureOwner
data Cat = Cat { catOwner :: PetOwner } data Chair = Chair { chairOwner :: FurnitureOwner }
class Owned a b | a -> b where owner :: a -> b
instance Owned Cat PetOwner where owner = catOwner
instance Owned Chair FurnitureOwner where owner = chairOwner
This is fairly onerous for people who are programming to an outside schema (i.e. a relational database) as it leads to boiler plate along two axes - data type definitions plus class definitions for accessors. I don't like the details current TDNR proposal, but if improved records are never going to happen, TDNR has benefit for this situation. Incidentally there is now a member of the ML family with a sophisticated record system - MLPolyR: http://ttic.uchicago.edu/~wchae/wiki/pmwiki.php