[Haskell-cafe] basic field questions

jamin1001 jamin1001 at yahoo.com
Wed Jan 24 06:12:17 EST 2007


Hi, I am new at Haskell and have some basic questions.

Is there any way to do this more effectively? This causes the GHC 
compile error "Multiple declarations of Main.test":

data A = A {test :: Int} 
data B = B {test :: Int} 


The Haskell 98 report in 4.2.1 under Labelled Fields says 
"A label cannot be shared by more than one type in scope. Field names 
share the top level namespace with ordinary variables and class methods 
and must not conflict with other top level names in scope." 


So then how should this be done?  What if I want to do something like 

data Chair = Chair {pos:: Int, color :: Int} 
data Table = Table {pos:: Int, color :: Int} 


Also, could someone tell me why this doesn't compile in GHC:

data Test = A {a::Int} | B {a::Int, b::Int}
data Test2 = C {c::A}

(Test2 line): Not in scope: type constructor or class 'A'


Is there a way to qualify identical field names?  What are some standard
practices for dealing with this?



Thanks,

Jamin Ohmoto-Frederick
-- 
View this message in context: http://www.nabble.com/basic-field-questions-tf3080392.html#a8558522
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list