[Haskell-beginners] GLfloat cast... have I got it right?

Sean Charles sean at objitsu.com
Thu Jul 7 18:19:35 CEST 2011


As I chunder on through OpenGL-land with Haskell I find things that 
sometimes confuse me!
Is there some kind of assumption being made here about the remaining two 
zeros?

  color $ Color3 (0::GLfloat) 0 0

I can see that is is typing the first zero to GLfloat but why don't I 
need to do it to the remaining two zeros?

Color3 is "Color3 !a !a !a"

The !a is, IIUIC, a strictness instruction that ensures that whatever 
expression I put here is evaluated immediately i.e. no thunk is 
generated and presumably no space leaks either: something rendering at 
60 fps with 'interesting' calculations for RGB values for example could 
cripple the application!

But back to the syntax: I am guessing (and hoping I've got it right for 
the *right* reasons) that it works because the definition says "a" for 
all three and that explicitly typing the first one automatically tells 
(infers!) the type inference system that the other two are to be treated 
as GLfloat types too.

:)




More information about the Beginners mailing list