我是 Haskell 的新手,今天我阅读了 OpenGL 源代码,发现了这个
data VertexArrayDescriptor a =
VertexArrayDescriptor !NumComponents !DataType !Stride !(Ptr a)
deriving ( Eq, Ord, Show )
http://hackage.haskell.org/package/OpenGL-2.9.1.0/docs/src/Graphics-Rendering-OpenGL-GL-VertexArrays.html#VertexArrayDescriptor http://hackage.haskell.org/package/OpenGL-2.9.1.0/docs/src/Graphics-Rendering-OpenGL-GL-VertexArrays.html#VertexArrayDescriptor
我尝试搜索并发现http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/bang-patterns.html http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/bang-patterns.html但这可能是不同的东西。
它有什么作用?它是做什么用的?
它是为了让在 Haskell 中编写严格的程序变得更容易,并使严格性更方便开发人员避免仅仅为了方便而被迫变得“懒惰”或不严格。
举个例子:
> data PNat = PZero | PSuc !Nat deriving Show
爆炸宣告PSuc
它的参数是严格的,即 PSuc Bottom = Bottom(其中 Bottom 是一个非终止表达式)。
它是为了表明模式的严格性:
f !x !y = x + y
很好的参考:https://ghc.haskell.org/trac/haskell-prime/wiki/BangPatterns https://ghc.haskell.org/trac/haskell-prime/wiki/BangPatterns
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)