[Haskell-cafe] opengl type confusion

briand at aracnet.com briand at aracnet.com
Sun Jun 16 22:03:48 CEST 2013


This,

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

produces this:

    No instance for (VertexComponent Double)
      arising from a use of `vertex'
    Possible fix:
      add an instance declaration for (VertexComponent Double)
    In the expression: vertex
    In a stmt of a 'do' block: vertex $ Vertex3 0.0 wy 0.0
    In the second argument of `($)', namely
      `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 }'

and thusly this :-(

Changing the declaration to GLdouble -> GLdouble -> GLdouble -> IO() and using
(0.0::GLdouble) fixes it, and I'm not clear on why it's not automagic.  There are many times I see the compiler doing type conversion an numerican arguments although sometimes the occasional fracSomethingIntegralorOther is required.

I was hoping for some enlightenment.

Thank you.

Brian




More information about the Haskell-Cafe mailing list