C ライブラリのラッパーを作成しようとしています。そして、これまでに見たことのない疑問符を含む奇妙な構文があります。
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
コンパイル時に構文エラーが発生します。
src/System/FlyCap.hs:185:21: parse error on input ‘?’
見上げる "?" on 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);
.... }
どのように進めればよいか本当にわかりません。任意のヒント?
更新:元のレポを見つけました。これにより、これが修正されたようですが、疑問符は何なのだろうか?