Makes it easy to write Mathematicapackages in Haskell. Just write some functions and provide a package specification in a simple DSL that mimics that of Mathematica's mpreputility.
Data marshaling is accomplished via the MLGetand MLPutclasses, which specify types that that can be read from or written to the
MathLinkconnection. Instances of these classes are provided for the obvious standard data types, including tuples, lists, and UArrays.
A Haskell function that is to be exposed to Mathematicahas the type signature (MLGeta, MLPutb) => a -> MLb. The MLmonad provides single-threaded access to the MathLinkconnection.
A simple example of a Mathematicapackage:
import Foreign.MathLink -- define a function addTwo :: (Int,Int) -> ML Int addTwo (x,y) = return $ x+y -- specify a package spec :: MLSpec spec = -- start a package definition [ Eval $ "BeginPackage":@[St "Test`"] -- define a usage message for the public symbol , DeclMsg "AddTwo" "usage" "AddTwo[..] adds a pair of numbers" -- open a new (private) namespace , Eval $ "Begin":@[St "`Private`"] -- declare the function , DeclFn { callPattern = "AddTwo[x_Integer,y_Integer]" , argPattern = "{x,y}" , func = addTwo } -- close the namespaces , Eval $ "End":@[] , Eval $ "EndPackage":@[] ] -- runs the MathLinkconnection main :: IO () main = runMathLink spec
No changelog available