[Haskell-cafe] Trouble with record syntax and classes

Albert Y. C. Lai trebla at vex.net
Mon Feb 26 17:10:10 EST 2007


All record fields are in the same namespace, and furthermore this is 
also the same namespace of functions and class methods. In other words 
you cannot have two record types containing the same field name, and you 
cannot have a record field and a function using the same name, and you 
cannot have a record field and a class method using the same name. You 
have to choose some other names for the fields of Sine, and yet some 
other names for the fields of MetaSine.

In "instance Sine ISine where ...", you must implement the methods 
"period", "offset", and "threshold", not just "act". Similarly for 
"instance MetaSine ISine where ...".

The implementations of method "act" are syntactically wrong as well as 
semantically wrong. I do not know what is a right implementation. 
Actually given the overly general signature

   act :: (ISine b) => Integer -> a -> b

I do not think there is any possible implementation at all. I submit 
that you have set a goal too ambitious and too magical.


More information about the Haskell-Cafe mailing list