How to write this correct...

Hi, I have the following problem: Vertex3 ist defined as data Vertex3 a = Vertex3 a a a a is defined as class a VertexComponent But I fail to write to following correct type GLVertex = (GLfloat, GLfloat, GLfloat) toVertex :: GLVertex -> Vertex3 a <<<<<<<< how do it correctly toVertex (x,y,z) = Vertex3 x y z The compiler says "cannot infer a with type GLFloat" or something like this.... I don't understand. Thank you for help Hans

On Sunday 22 Feb 2004 10:03 am, Hans Nikolaus Beck wrote:
Hi,
I have the following problem:
Vertex3 ist defined as
data Vertex3 a = Vertex3 a a a
a is defined as
class a VertexComponent
But I fail to write to following correct
type GLVertex = (GLfloat, GLfloat, GLfloat)
toVertex :: GLVertex -> Vertex3 a <<<<<<<< how do it correctly toVertex (x,y,z) = Vertex3 x y z
The compiler says "cannot infer a with type GLFloat" or something like this.... I don't understand.
Thank you for help
The type signature is wrong. Try this.. toVertex :: GLVertex -> Vertex3 GLfloat or perhaps.. toVertex :: (a,a,a) -> Vertex3 a Regards -- Adrian Hey

Hi,
The type signature is wrong. Try this.. toVertex :: GLVertex -> Vertex3 GLfloat
or perhaps.. toVertex :: (a,a,a) -> Vertex3 a
Regards
Yes this works (the first variant). Thanks ! But I must say that I have problems to understand the class mechanism in its full extend.... Greetings Hans

HNBeck@t-online.de (Hans Nikolaus Beck) writes:
type GLVertex = (GLfloat,GLfloat,GLfloat)
toVertex :: GLVertex -> Vertex3 GLfloat toVertex :: (a,a,a) -> Vertex3 a
Yes this works (the first variant). Thanks ! But I must say that I have problems to understand
The problem is that you tried to tell the compiler that toVertex would return a parametrised type, namely 'Vertex3 a', but that the compiler sees that toVertex, when given a 'GLVertex' always will produce 'Vertex3 GLfloat'.
the class mechanism in its full extend....
Classes doesn't have anything to do with this. -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (3)
-
Adrian Hey
-
HNBeck@t-online.de
-
Ketil Malde