无法推断使用" color"

时间:2017-11-16 11:20:31

标签: haskell opengl glut

我得到了一个"无法演绎"我尝试在GLUT中调用颜色时出错。

Could not deduce (ColorComponent Float)
  arising from a use of ‘color’
from the context (RealFloat a, VertexComponent a)
  bound by the inferred type of
           drawVert :: (RealFloat a, VertexComponent a) => Vertex2 a -> IO ()
  at double.hs:(39,1)-(40,24)
In the first argument of ‘(.)’, namely ‘color’
In the expression: color . getcolor
In a stmt of a 'do' block: color . getcolor $ mandel v

这是我的代码:

import Graphics.UI.GLUT
import Control.Monad
import Data.Int
import Data.Complex
drawVert v = do color . getcolor $ mandel v
                vertex v
mandel (Vertex2 r i) = length . takeWhile (\z -> magnitude z <= 2) .
                       take iterations $ iterate (\z -> z^2 + (r :+ i)) 0
getcolor :: Int -> Color3 Float
getcolor iter | iter == iterations = color3 0 0 0
              | otherwise          = color3 (amt*0.5) amt (amt*0.5)
              where amt = iter // iterations

我怀疑OpenGL和GLUT都包含颜色,而且haskell不知道应该使用哪种颜色。但是如何解决呢?

0 个答案:

没有答案
相关问题