Haskell and Maple FFI

2004-09-17 Thread Rafael Martinez Torres
Hello: I would like to implement a new "calling convention" for Maple language, so that programers in Haskell may call for Maple routines. Both languages are intereseting for cooperation, due to its symbolic expresiveness. Maple 9.3 has released "Open Maple", somewhat like JNI for Java, if I'm no

Re: Haskell and Maple FFI

2004-09-17 Thread Alastair Reid
> I would like to implement a new "calling convention" for Maple > language, so that programers in Haskell may call for Maple routines. > Both languages are intereseting for cooperation, due to its symbolic > expresiveness. Making it possible to call Maple would be very cool. Can you give more d

Re: Haskell and Maple FFI

2004-09-20 Thread Rafael Martinez Torres
> > Making it possible to call Maple would be very cool. Can you give more detail > about Open Maple? > Description OpenMaple is a suite of functions that allows you to access Maple algorithms and data structures in your compiled C program. This is the reverse of ExternalCalling, which allows

Re: Haskell and Maple FFI

2004-09-20 Thread Alastair Reid
> Examples ( taken from Open Maple ) > > ALGEB M_DECL MyStats( MKernelVector kv, ALGEB *args ) > { > ALGEB mean, sd, f; > > if( 1 != MapleNumArgs(kv,(ALGEB)args) ) { > MapleRaiseError(kv,"one argument expected"); > return( NULL ); > } > ... >

Re: Haskell and Maple FFI

2004-10-21 Thread Rafael Martinez Torres
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.

Re: Haskell and Maple FFI

2004-10-21 Thread Rafael Martinez Torres
> > B) When passing char *string on C, should I use > the CString or the Ptr CChar marhalling type from FFI ? > Ok. I see. Definition for CSTring is type CString = Ptr CChar C) CInt, CDouble are available...but, concerning Storable class. Given: typedef struct _foostruct { int a; doub

Re: Haskell and Maple FFI

2004-10-21 Thread Rafael Martinez Torres
> - > 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 ->

Re: Haskell and Maple FFI

2004-10-21 Thread Sven Panne
Rafael Martinez Torres wrote: Done. Upgrading ghc-6.0.1 solves it. Why not 6.2.2? 6.0.1 is relatively old... Still waiting for answer C) on how marshalling C structures... Perhaps a look at http://www.reid-consulting-uk.ltd.uk/docs/ffi.html and probably http://haskell.org/ghc/docs/latest/html

Re: Haskell and Maple FFI

2004-10-21 Thread Rafael Martinez Torres
> > > C) CInt, CDouble are available...but, concerning Storable class. > > Given: > typedef struct _foostruct { > int a; > double b; > } fooStruct, *fooStructPtr; > > How to do to marshall it to Haskell ? > > type CFooStruct = ??? > > instance Storable CFooStruct where >sizeOf _ = ??

Re: Haskell and Maple FFI

2004-10-21 Thread Sven Panne
Rafael Martinez Torres wrote: Well, after reading some doc, I realised it may not be feasible without a FFI preprocessor. It's feasible without a FFI preprocessor, but probably not very portable. For the time beeing, as I don't want to access the internals of Kernel descriptor, but to deal with it

Re: Haskell and Maple FFI [RELASED 0.0.1]

2004-10-22 Thread Rafael Martinez Torres
> > Yes, now use Haskell's ffi to import all those OpenMaple calls you made in the > above. That is, MapleNumArgs, ToMapleExpressionSequence, etc. > > Having done that, translate the code into Haskell in the obvious way and check > it works. > Done !!! > After you've done a bunch of examples, s