[Haskell-cafe] Haskell record extension?

bf3 at telenet.be bf3 at telenet.be
Fri Jun 15 17:24:58 EDT 2007


I'm learning Haskell. 

I was surprised that the following example did not compile:

data Vector2 = Vector2 { x :: Float, y :: Float }
data Vector3 = Vector3 { x :: Float, y :: Float, z :: Float }

error: "Multiple declarations of `Main.x'"

This seems to be a known issue and if I understand it correctly it has to do
with the fact that Haskell does not support function general overloading ala
C++. One either has to use type classes, or put each record in a separate
module and fiddle with the qualified namespaces.

I read multiple papers with proposals to fix this, but does GHC implement
any of these?

Thanks,
Peter







More information about the Haskell-Cafe mailing list