[Haskell-cafe] Type Directed Name Resolution

Stephen Tetley stephen.tetley at gmail.com
Thu Nov 11 08:53:20 EST 2010


On 11 November 2010 13:10, Lauri Alanko <la at iki.fi> wrote:

>
> {-# 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


More information about the Haskell-Cafe mailing list