You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to export a module with own types with the following code:
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE TemplateHaskell #-}
module RectangleMover where
import Foreign.C
import FFI.Anything.TypeUncurry.Msgpack
data Point = Point Int Int
movePoint :: Point -> Int -> Int -> Point
movePoint (Point x y) dx dy = Point (x + dx) (y + dy)
data Rectangle = Rectangle { corner :: Point, width :: Int, height :: Int }
move :: Rectangle -> Int -> Int -> Rectangle
move r@(Rectangle {corner=c}) dx dy = r { corner = movePoint c dx dy }
foreign export ccall move_export :: CString -> IO CString
move_export :: CString -> IO CString
move_export = export move
But when i try to compile this i get the this error message:
[1 of 1] Compiling RectangleMover ( test.hs, test.o )
test.hs:19:15:
No instance for (Data.MessagePack.Object.MessagePack Rectangle)
arising from a use of ‘export’
In the expression: export move
In an equation for ‘move_export’: move_export = export move
What am i missing? Or does this package support exporting own types at all?
The text was updated successfully, but these errors were encountered:
manzznam
changed the title
Exporting own type "Rectangle"
Exporting own "data" type
Jul 3, 2016
In other words, the type constituents of f (in other words, the respective types of its inputs and outputs) have to be instances of MessagePack (see the msgpack package). Your Rectangle type is missing such an instance.
I am trying to export a module with own types with the following code:
But when i try to compile this i get the this error message:
What am i missing? Or does this package support exporting own types at all?
The text was updated successfully, but these errors were encountered: