# mathlink: Write Mathematica packages in Haskell

Makes it easy to write *Mathematica* packages in Haskell. Just write some
functions and provide a package specification in a simple DSL that
mimics that of *Mathematica*'s `mprep`

utility.

Data marshaling is accomplished via the `MLGet`

and `MLPut`

classes, which
specify types that that can be read from or written to the *MathLink*
connection. Instances of these classes are provided for the obvious
standard data types, including tuples, lists, `Array`

s and `UArray`

s.

A Haskell function that is to be exposed to *Mathematica* has the type
signature `(`

.`MLGet`

a, `MLPut`

b) => a -> IO b

A simple example of a *Mathematica* package:

import Foreign.MathLink -- define a function addTwo :: (Int,Int) -> IO 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 theMathLinkconnection main :: IO () main = runMathLink spec

Versions [faq] | 0.1.0.0, 0.1.0.1, 0.1.0.2, 1.0.0.0, 1.0.0.1, 1.1.0.0, 1.1.0.1, 1.1.0.2, 2.0.0.3, 2.0.0.4, 2.0.0.5, 2.0.0.7, 2.0.1.1 |
---|---|

Dependencies | array (==0.2.*), base (>=4.0 && <4.2), containers (==0.2.*), haskell98, ix-shapable, mtl (==1.1.*) [details] |

License | BSD-3-Clause |

Copyright | Copyright (c) Tracy Wadleigh 2009 |

Author | Tracy Wadleigh |

Maintainer | <tracy.wadleigh@gmail.com> |

Category | Foreign |

Home page | http://community.haskell.org/~TracyWadleigh/mathlink |

Bug tracker | mailto:tracy.wadleigh@gmail.com?subject=dev-mathlink |

Source repo | head: darcs get http://community.haskell.org/~TracyWadleigh/darcs/mathlink/ |

Uploaded | by TracyWadleigh at 2009-05-18T00:33:08Z |

Distributions | NixOS:2.0.1.1 |

Downloads | 7999 total (43 in the last 30 days) |

Rating | (no votes yet) [estimated by Bayesian average] |

Your Rating | |

Status | Docs not available [build log] All reported builds failed as of 2017-01-01 [all 6 reports] |

## Modules

*Foreign*- Foreign.MathLink
- Foreign.MathLink.Expression
- Foreign.MathLink.Internal

- Foreign.MathLink

## Downloads

- mathlink-2.0.0.3.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)