[Haskell-cafe] OpenGL: No instance for Random GLfloat

Mark Spezzano mark.spezzano at chariot.net.au
Thu May 3 00:29:03 CEST 2012


Hi Haskellers,

I'm trying to generate a random vertex in OpenGL as follows.

genPosition :: IO (Vertex3 GLfloat)
genPosition = do x <- getStdRandom $ randomR (-1.6,1.6)
                               y <- getStdRandom $ randomR (-1.0,1.0)
                              return (Vertex3 x y (-1))

Unfortunately the compiler complains about me having to implement an instance of Random for  GLfloat.

How do I do this (or avoid having to do this)?

Cheers,

Mark




More information about the Haskell-Cafe mailing list