Haskell and Maple FFI

Rafael Martinez Torres rmartine at fdi.ucm.es
Thu Sep 16 07:41:22 EDT 2004


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 not wrong. So a good start point to conider how
to marshall these environments...

I'm a newbie on FFI. Help required specilly from those working on Java
FFI. Sorry for the obscure points.

1.- My initial schema is:

C --------> Java	Haskell --------> Maple

A C programmer invokes the Java Virtual Machine as a Haskell programmer
 will invoke the Maple "kernel" handle (MKV).

(  Strictly speaking, this
should be done by the "calling convention" mechanism in a trasnparent
way, since the final
user has only to program the maple routines and to use the mandatory
declarations:

foreign import c e v :: t
foreign export c e v :: t

file a.maple:
-------------
 proc e(a,b)
 return a+b;
 end;

)

2.- The JVM initializes on a ".class" file, i.e, byte-code, as MKV
 straightly on source language ".maple" .

3.- What a "calling convention" must implement ? How to implement it ?

I mean, JNI exports marshalling/unarshalling of types from Java to C, and
access to attrbiutes/ invokes of methods of a given object on Java..


In time, Open Maple exports marshalling/unmarshalling of types between
Maple AND C, and several ways of invoke the maple-kernel.

 So I should implement Maple and Haskell marshalling -via C , right ?
I should implement the "maple" convention by using the "ccall" convention.

So, there is a sort of "template" to implement a "calling convention"?
This is a obscure point for me...

4.-  What about side effects ? I mean, invoking a function on Maple may
change the state of interpreter, and further calls may diff. Should I pass
to the final user a handle to the KVM , or create a new type of monad, like...

	type MapleMonad a = stateKVM-> (stateKVM,val)
	instance Monad MapleMonad a ...
	>>=
	>>
	..



More information about the FFI mailing list