[Haskell-cafe] opengl type confusion

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sun Jun 16 23:19:22 CEST 2013


On Sun, Jun 16, 2013 at 01:03:48PM -0700, briand at aracnet.com wrote:
> wireframe :: Double -> Double -> Double -> IO ()
> wireframe wx wy wz = do 
>   -- yz plane
>   renderPrimitive LineLoop $ do
>                        vertex $ Vertex3 0.0 0.0 0.0
>                        vertex $ Vertex3 0.0 wy 0.0
>                        vertex $ Vertex3 0.0 wy wz
>                        vertex $ Vertex3 0.0 0.0 wz
[...]
> 
>     No instance for (VertexComponent Double)
>       arising from a use of `vertex'
[...]
> 
> Changing the declaration to GLdouble -> GLdouble -> GLdouble -> IO() and using
> (0.0::GLdouble) fixes it

Vertex3 takes three arguments, all of which must be of the same instance of
VertexComponent.  Specifying GLdoubles in the signature of wireframe
specifies the types in the last three calls to Vertex3, but (0.0 ::
GLdouble) is still requried on the first to fix the type there.  How else
could the compiler know that you mean 0.0 to be a GLdouble and not a
GLfloat?

Tom



More information about the Haskell-Cafe mailing list