Opencv Haskell中的问号关键字

Opencv Haskell中的问号关键字,opencv,haskell,flycapture,Opencv,Haskell,Flycapture,它有一些奇怪的带有问号的语法,我以前从未见过: cvLoadImage :: Capture -> IO CImage cvLoadImage capture = do (Just imageRGB) <- getFrame capture let imageD32 = rgbToGray imageRGB let (CArray (nx0, ny0) (nx1, ny1) numElem values) = copyImageToFCArray imageD32

它有一些奇怪的带有问号的语法,我以前从未见过:

cvLoadImage :: Capture -> IO CImage
cvLoadImage capture = do
   (Just imageRGB) <- getFrame capture
   let imageD32 = rgbToGray imageRGB
   let (CArray (nx0, ny0) (nx1, ny1) numElem values) = copyImageToFCArray imageD32
   pixelVals <- (withForeignPtr values) (peekArray numElem)
   let pixelVals' = map (fromIntegral . truncate . (*255)) pixelVals
   ptr <-( mallocArray (numElem) ::IO (Ptr Word8))
   pokeArray ptr pixelVals'
   return CImage (? ? ? pixelVals' ? ? ? ?) -- this is the line I'm confounded by
在Hoogle上查找“?”找到了一些关于的内容,但这似乎没有关系。我试着用类型孔替换神秘的问号:

 return CImage (_ _ _ pixelVals' _ _ _ _)
这给了我一个更大的错误:

src/System/FlyCap.hs:186:4:
    Couldn't match type ‘IO CImage’
                  with ‘CUInt
                        -> CUInt
                        -> CUInt
                        -> Ptr CUChar
                        -> CUInt
                        -> CInt
                        -> CInt
                        -> Ptr ()
                        -> CImage’
    Expected type: t6 -> IO CImage
      Actual type: t6
                   -> CUInt
                   -> CUInt
                   -> CUInt
                   -> Ptr CUChar
                   -> CUInt
                   -> CInt
                   -> CInt
                   -> Ptr ()
                   -> CImage
    The function ‘return’ is applied to two arguments,
    but its type ‘(CUInt
                   -> CUInt
                   -> CUInt
                   -> Ptr CUChar
                   -> CUInt
                   -> CInt
                   -> CInt
                   -> Ptr ()
                   -> CImage)
                  -> t6
                  -> CUInt
                  -> CUInt
                  -> CUInt
                  -> Ptr CUChar
                  -> CUInt
                  -> CInt
                  -> CInt
                  -> Ptr ()
                  -> CImage’
    has only 10
    In a stmt of a 'do' block: return CImage (_ _ _ pixelVals' _ _ _ _)
    In the expression:
      do { (Just imageRGB) <- getFrame capture;
           let imageD32 = rgbToGray imageRGB;
           let (CArray (nx0, ny0) (nx1, ny1) numElem values)
                 = copyImageToFCArray imageD32;
           pixelVals <- (withForeignPtr values) (peekArray numElem);
           .... }
src/System/FlyCap.hs:186:4:
无法匹配类型“IO CImage”
有“提示”
->线索
->线索
->库查尔
->线索
->辛特
->辛特
->Ptr()
->CImage'
预期类型:t6->IO CImage
实际型号:t6
->线索
->线索
->线索
->库查尔
->线索
->辛特
->辛特
->Ptr()
->CImage
函数“return”应用于两个参数,
但是它的类型是
->线索
->线索
->库查尔
->线索
->辛特
->辛特
->Ptr()
->CImage)
->t6
->线索
->线索
->线索
->库查尔
->线索
->辛特
->辛特
->Ptr()
->CImage'
只有10个
在“do”块的stmt中:返回CImage(
在表达式中:

do{(仅仅是imageRGB)这个
不是一个语法,它是haskell中的一个有效操作符。但是这里它只是一个“这里有魔力”的东西

如上所述,作者只是忘了用一些涉及
pixelVals'
的表达式来替换它。很可能,它应该是用该像素值构造
CImage
参数


Ghc的解析器将在由运算符符号构成的任意两个连续标记(除了
-
)上给出
parse error
)-因为在第二个问号后失败。

您确定它们不仅仅是作者忘记填写的东西吗?
src/System/FlyCap.hs:186:4:
    Couldn't match type ‘IO CImage’
                  with ‘CUInt
                        -> CUInt
                        -> CUInt
                        -> Ptr CUChar
                        -> CUInt
                        -> CInt
                        -> CInt
                        -> Ptr ()
                        -> CImage’
    Expected type: t6 -> IO CImage
      Actual type: t6
                   -> CUInt
                   -> CUInt
                   -> CUInt
                   -> Ptr CUChar
                   -> CUInt
                   -> CInt
                   -> CInt
                   -> Ptr ()
                   -> CImage
    The function ‘return’ is applied to two arguments,
    but its type ‘(CUInt
                   -> CUInt
                   -> CUInt
                   -> Ptr CUChar
                   -> CUInt
                   -> CInt
                   -> CInt
                   -> Ptr ()
                   -> CImage)
                  -> t6
                  -> CUInt
                  -> CUInt
                  -> CUInt
                  -> Ptr CUChar
                  -> CUInt
                  -> CInt
                  -> CInt
                  -> Ptr ()
                  -> CImage’
    has only 10
    In a stmt of a 'do' block: return CImage (_ _ _ pixelVals' _ _ _ _)
    In the expression:
      do { (Just imageRGB) <- getFrame capture;
           let imageD32 = rgbToGray imageRGB;
           let (CArray (nx0, ny0) (nx1, ny1) numElem values)
                 = copyImageToFCArray imageD32;
           pixelVals <- (withForeignPtr values) (peekArray numElem);
           .... }