jamin1001 wrote:
What if I want to do something like
data Chair = Chair {pos:: Int, color :: Int}
data Table = Table {pos:: Int, color :: Int}
data Properties = Props { pos, color :: Int }
data Chair = Chair Props
data Table = Table Props
or:
data Chair = Chair Int Int
data Table = Table Int Int
class Furniture a where
pos :: a -> Int
color :: a -> Int
instance Furniture Chair where
pos (Chair x _) = x
color (Chair _ c) = c
instance Furniture Table where ...
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'
A is a data constructor, and not a type. Try:
data Test2 = C { c :: Test }
Is there a way to qualify identical field names? What are some standard
practices for dealing with this?
The record system is somewhat wartish, and there have been
several proposals to remedy it. I'm not sure if any consensus
has emerged yet.
-k
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe