我试图Foreign.C.Types在Haskell中使用C调用Haskell,但它在编译器中始终显示此错误:
Run Code Online (Sandbox Code Playgroud)* Unacceptable argument type in foreign declaration: `(CInt, CInt)' cannot be marshalled in a foreign call * When checking declaration: foreign export ccall "func_hs" func_hs :: (CInt, CInt) -> CInt | 15 | foreign export ccall func_hs :: (CInt, CInt) -> CInt | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
GHCi版本8.6.3编译的确切代码:
{-# LANGUAGE ForeignFunctionInterface #-}
module Func where
import Foreign.C.Types
verify_hp :: (CInt, CInt) -> CInt
verify_hp (hp, maxHp) = if hp < maxHp then hp + 10 else maxHp
func_hs :: (CInt, …Run Code Online (Sandbox Code Playgroud)