[Haskell-cafe] opengl type confusion
briand at aracnet.com
briand at aracnet.com
Mon Jun 17 02:22:59 CEST 2013
On Sun, 16 Jun 2013 22:19:22 +0100
Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
> 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
>
it's curious that
(0.0::GLdouble) 0.0 0.0
is good enough and that
(0.0::GLdouble) (0.0::GLdouble) (0.0::GLdouble)
is not required. I suspect that's because, as you point out, they all have to be the same argument and ghc is being smart and saying if the first arg _must_ be GLdouble (because I'm explicitly forcing the type), then the rest must be too.
Meanwhile 4.3.4 about the default is quite interesting. Didn't know about that :-)
Thanks very much for the responses !
Brian
More information about the Haskell-Cafe
mailing list