mathlink 1.1.0.1 → 1.1.0.2
raw patch · 2 files changed
+30/−21 lines, 2 files
Files
- mathlink.cabal +8/−7
- src/Foreign/MathLink.hs +22/−14
mathlink.cabal view
@@ -1,5 +1,5 @@ Name: mathlink-Version: 1.1.0.1+Version: 1.1.0.2 Cabal-Version: >= 1.6 Build-Type: Simple License: BSD3@@ -24,13 +24,14 @@ Provides a simple way to expose Haskell functions to /Mathematica/ via the /MathLink/ interface. .-One defines a Haskell function of type @IO ()@ and provides a pair of -'String's that function analogously to the @:Pattern:@ and @:Arguments:@ -directives for /Mathematica/'s @mprep@ utility.+One defines a Haskell function of type +@('Expressible' e1, 'Expressible' e2) => e1 -> 'IO' e2@ +and provides a pair of 'String's that function analogously to the +@:Pattern:@ and @:Arguments:@ directives for /Mathematica/'s @mprep@ +utility. .-Data whose types are instances of the 'Expressible' class can be marshaled-to\/from /Mathematica/. The library already provides instances for many-data types, including tuples, lists, and unboxed arrays.+The library provides instances of the 'Expressible' class for many data +types, including tuples, lists, arrays, and unboxed arrays. . The library does not use or require @foreign export@ declarations, so may be used interactively.
src/Foreign/MathLink.hs view
@@ -4,8 +4,12 @@ #-} -- | A Haskell interface to /Mathematica/'s /MathLink/.-module Foreign.MathLink ( -- * Basic usage+module Foreign.MathLink ( -- * Installation notes + -- $installation++ -- * Basic usage+ -- $usage -- * Exposing Functions@@ -266,6 +270,18 @@ -- extra documentation +{- $installation++ The cabal file isn't very sophisticated, so you need to help it out a +little. For instance:++ - The @mathlink.h@ header needs to be accessible by default.+ + - If yours is a 32-bit system, you may need to explicitly set the 32Bit + flag.++ -}+ {- $usage The following is a small Haskell module that exposes a function callable from /Mathematica/ that gets a pair of 'Int's (as a tuple) and @@ -276,22 +292,14 @@ import 'Foreign.MathLink' -addTwo :: 'IO' ()-addTwo = do- (i1,i2) <- 'get'- 'put' ((i1 + i2) :: 'Int')+addTwo :: ('Int','Int') -> 'IO' 'Int'+addTwo (i1,i2) = return (i1+i2) -main = 'runMathLink' [ 'Function' \{ 'callPattern' = \"AddTwo[i_Integer,j_Integer]\"- , 'argumentPattern' = \"{i,j}\"- , 'function' = addTwo- \}+main = 'runMathLink' [ 'mkFunction' \"AddTwo[i_Integer,j_Integer]\"+ \"{i,j}\"+ addTwo ] @--A function to be exposed to /Mathematica/ has type @'IO' ()@. In its body -it uses the 'get' function to receive a value from /Mathematica/, performs -the desired computation, and sends the result back to /Mathematica/ via the -'put' function. The types that can be marshaled to\/from /Mathematica/ are instances of the 'Expressible' class.