如何在runContextT中使用threadDelay

时间:2016-12-18 22:39:38

标签: haskell monads

我正在学习Haskell。 (使用GPipe)

我有以下代码,它是在屏幕上绘制三角形的程序的一部分:

drawyRun :: IO ()
drawyRun = do
  runContextT GLFW.newContext (ContextFormatColor RGB8) $ do
    threadDelay 10
    vertexBuffer :: Buffer os (B4 Float, B3 Float) <- newBuffer 3
    writeBuffer vertexBuffer 0 [ (V4 (-1) 1 0 1, V3 1 0 0)
                               , (V4 0 (-1) 0 1, V3 0 1 0)
                               , (V4 1 1 0 1,  V3 0 0 1)
                               ]

    shader <- compileShader mainShader

    loop vertexBuffer shader 0.0

该行threadDelay 10正在给出编译器错误:

Couldn't match type ‘IO’
                     with ‘ContextT GLFW.GLFWWindow os (ContextFormat RGBFloat ()) IO’
      Expected type: ContextT
                       GLFW.GLFWWindow os (ContextFormat RGBFloat ()) IO ()
        Actual type: IO ()

如何在runContextT内引起短暂延迟?

0 个答案:

没有答案