nh2 / nh2/call-haskell-from-anything

Exporting own "data" type

Abierto
#17 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Haskell
Estrellas
402
Forks
20
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.