C++ 将自定义数据类型列表从Haskell传递到C++;
我使用Haskell函数到C++程序中使用<代码>导出CCAL> <代码> < < 将基本类型从一种语言传递到另一种语言很容易,但如何传递更复杂的类型,如以下类型:C++ 将自定义数据类型列表从Haskell传递到C++;,c++,haskell,custom-data-type,C++,Haskell,Custom Data Type,我使用Haskell函数到C++程序中使用导出CCAL> < < 将基本类型从一种语言传递到另一种语言很容易,但如何传递更复杂的类型,如以下类型: piecesList::[Piece] piecesList = [Piece _type _color _coords, ..., ... Piece _type _color _coords] 与: data Piece = Piece { _type :: PieceType, _color :: PieceColor, _po
piecesList::[Piece]
piecesList = [Piece _type _color _coords, ..., ... Piece _type _color _coords]
与:
data Piece = Piece {
_type :: PieceType,
_color :: PieceColor,
_position :: Position
} deriving Eq
data PieceColor = Black | White deriving Eq
data PieceType = Rook | Knight | Bishop | King | Queen | Pawn deriving Eq
type Position = (Int, Int)
如果我这样做(例如):
及
我得到:
Unacceptable result type in foreign declaration:
‘[Piece]’ cannot be marshalled in a foreign call
• When checking declaration:
foreign export ccall "get_piecesList" get_piecesList :: [Piece]
如何传递这种数据,如何处理C++?< /P>
谢谢
我想你也已经有了一个C++类<代码>块<代码>,你想把它映射到什么?然后将其存储为std::vector
,或者什么?这也是问题中应该包含的内容……请参阅。你可能也应该四处寻找帮助的工具,因为这是一种痛苦。好吧,看起来确实是一种痛苦。。。我要用另一种方式来做。谢谢你也已经有了C++类<代码>块<代码>,你想把它映射到什么?然后将其存储为std::vector
,或者什么?这也是问题中应该包含的内容……请参阅。你可能也应该四处寻找帮助的工具,因为这是一种痛苦。好吧,看起来确实是一种痛苦。。。我要用另一种方式来做。谢谢
foreign export ccall get_piecesList :: [Piece]
Unacceptable result type in foreign declaration:
‘[Piece]’ cannot be marshalled in a foreign call
• When checking declaration:
foreign export ccall "get_piecesList" get_piecesList :: [Piece]