module Main where
import Graphics.Rendering.OpenGL
data Shaders = Shaders { vertexShader :: VertexShader
, fragmentShader :: FragmentShader
, program' :: Program
, positionA :: AttribLocation }
data Resources = Resources { vertexBuffer :: BufferObject
, elementBuffer :: BufferObject
, shaders :: Shaders
, fadeFactor :: GLfloat }
main :: IO ()
main = do
putStrLn "test"
这是 ghci 输出:
[1 of 1] Compiling Main ( /home/madjestic/Projects/Haskell/OpenGL/triangle_02/Main_test.hs, interpreted )
/home/madjestic/Projects/Haskell/OpenGL/triangle_02/Main_test.hs:11:45:
Not in scope: type constructor or class `VertexShader'
A data constructor of that name is in scope; did you mean -XDataKinds?
/home/madjestic/Projects/Haskell/OpenGL/triangle_02/Main_test.hs:12:45:
Not in scope: type constructor or class `FragmentShader'
A data constructor of that name is in scope; did you mean -XDataKinds?
Failed, modules loaded: none.
错误指出,类型或类构造函数不在范围内,但同时它说“该名称的数据构造函数在范围内......”,但建议使用 DataKinds,我不明白为什么我需要一个 - 相同的代码在我的旧 linux 机器上编译正常,没有 DataKinds 扩展,但它似乎在新环境中不起作用。我现在主要依赖于 portage 库,而旧环境更多地依赖于 cabal 库,我想知道这是否导致了差异?这里有什么问题?数据类型构造函数存在于正在导入的 Graphics.Rendering.OpenGL 中 - 为什么 ghc 不能在这里使用它?