On 4 Jan 2009, at 07:11, Thomas DuBuisson wrote:

My proposal would be for each selector name to be a special type of
"phantom" type class (existing in the intermediate language only).
This type class would not be accessible by the programmer and thus
s/he couldn't make a polymorphic function for which specialization
would be needed.  In other words -  in normal circumstances there is
no need for dictionaries and thus no run-time difference between this
method and using different record names.

Example:

data IPv4Hdr = Hdr4 { src, dst :: IPv4 }
data IPv6Hdr = Hdr6 { src, dst :: IPv6 }


At some intermediate stage you'd see:

class Src h s where
   src :: h -> s
class Dst h d where
   dst :: h -> d

class Src h s | h -> s
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to