Haskell and Maple FFI

Rafael Martinez Torres rmartine at fdi.ucm.es
Thu Oct 21 04:26:48 EDT 2004




On Mon, 20 Sep 2004, Alastair Reid wrote:

> >         }
> > ...
> >         /* return the pair */
> >         return( ToMapleExpressionSequence(kv,2,mean,sd) );
> >     }
> >
> > Is it what do you mean ?
>
> Yes, now use Haskell's ffi to import all those OpenMaple calls you made in the
> above.  That is, MapleNumArgs, ToMapleExpressionSequence, etc.
>

Now in progress...


> Having done that, translate the code into Haskell in the obvious way and check
> it works.
>

Two questions:
-------------
A) The H98 Foreign Function Interface remakrs the next example to import
from C.

foreign import ccall "string.h strlen" cstrlen:: Ptr CChar -> IO CSize

but trying

foreign import ccall "maplec.h MapleKernelOptions" mapleKernelOptions ::
MKernelVector ->  CString -> IO(ALGEB)

gives a failure. (ghc-5.02.3)
otium at avila:~/OpenMaple> ghc -cpp -fglasgow-exts -c maplec.hs -package lang

maplec.hs:82:
    `maplec.h MapleKernelOptions' is not a valid C identifier
    When checking declaration:
	foreign import __ccall_GC maplec.h MapleKernelOptions mapleKernelOptions :: MKernelVector
										    -> CString
										       -> IO ALGEB

It's a pitty, because I cannot use "MapleKernelOptions" as a identifier
for a function in Haskell....

What to do then ?



B)  When passing char *string on C, should I use
the CString or the Ptr CChar marhalling type from FFI ?




More information about the FFI mailing list