-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Call Haskell from Mathematica
--
-- Provides a simple way to expose Haskell functions to
-- Mathematica via the MathLink interface. One defines a
-- Haskell function of type ML () (a Monad built on top
-- of IO) and provides a pair of Strings that function
-- analogously to the :Pattern: and :Arguments:
-- directives for Mathematica's mprep utility. Data can
-- be marshaled either as an Expression or, more generally, as an
-- instance of the Expressible class. The library does not use or
-- require foreign export declarations, so may be used
-- interactively.
@package mathlink
@version 0.1.0.2
module Foreign.MathLink.Types
-- | Instances of Expressible are precisely the data types that can
-- be marshaled to and from Mathematica.
class Expressible a
put :: (Expressible a) => a -> ML ()
get :: (Expressible a) => ML a
-- | Arrays to be marshaled to and from Mathematica require indices
-- that are instances of Dimensional.
class (Ix ix) => Dimensional ix
rank :: (Dimensional ix) => ix -> Int
dimensions :: (Dimensional ix) => (ix, ix) -> [Int]
fromDimensions :: (Dimensional ix) => [Int] -> (ix, ix)
-- | Represents a general Mathematica expression.
data Expression
-- | An atomic value of integer type
ExInt :: Int -> Expression
-- | An atomic value of floating point type
ExReal :: Double -> Expression
-- | An atomic value of string type
ExString :: String -> Expression
-- | An atomic value of symbol type
ExSymbol :: String -> Expression
-- | A non-atomic value, with a head of type symbol and a list of arguments
ExFunction :: String -> [Expression] -> Expression
-- | The monad in which functions exposed to Mathematica execute.
newtype ML a
ML :: ErrorT String (StateT State (ReaderT Config IO)) a -> ML a
runMLMonad :: ML a -> ErrorT String (StateT State (ReaderT Config IO)) a
-- | Encapsulates the readable state associated with the ML monad.
data Config
Config :: Environment -> Link -> IntMap Function -> Config
environment :: Config -> Environment
link :: Config -> Link
functionTable :: Config -> IntMap Function
-- | Encapsulates a description of a function callable from
-- Mathematica
data Function
Function :: String -> String -> ML () -> Function
-- | A string representing the Mathematica pattern whose match
-- should result in a function call to the specified Haskell function.
-- Analogous to the :Pattern: directive in an input to
-- Mathematica's mprep utility.
callPattern :: Function -> String
-- | A string representing the Mathematica pattern for the argument
-- that will be marshaled from Mathematica to Haskell. Pattern
-- variables appearing here are bound in the callPattern match.
-- Analogous to the :Arguments: directive in an input to
-- Mathematica's mprep utility.
argumentPattern :: Function -> String
-- | The Haskell function to be invoked.
function :: Function -> ML ()
-- | Encapsulates the read/write state associated with the ML monad.
data State
State :: Bool -> Bool -> State
abort :: State -> Bool
done :: State -> Bool
-- | Runs the given ML computation with the given state and
-- configuration.
runML :: ML a -> State -> Config -> IO (Either String a)
-- | A wrapped pointer to the MathLink link.
newtype Link
Link :: Ptr () -> Link
-- | A wrapped pointer to the MathLink environment.
newtype Environment
Environment :: Ptr () -> Environment
-- | An enumeriation of possible return values from the MathLink
-- functions MLGetNext or MLGetType.
data Type
ErrorType :: Type
IntType :: Type
RealType :: Type
StringType :: Type
SymbolType :: Type
FunctionType :: Type
UnknownType :: Int -> Type
mkType :: (Integral a) => a -> Type
-- | An enumeration of MathLink message types.
data Message
TerminateMessage :: Message
InterruptMessage :: Message
AbortMessage :: Message
EndPacketMessage :: Message
SynchronizeMessage :: Message
ImDyingMessage :: Message
WaitingAcknowledgementMessage :: Message
MarkTopLevelMessage :: Message
LinkClosingMessage :: Message
AuthenticateFailureMessage :: Message
UserMessage :: Int -> Message
UnknownMessage :: Int -> Message
mkMessage :: (Integral a) => a -> Message
-- | An enumeration of some error codes defined in mathlink.h.
data Error
NoError :: Error
DeadLnkError :: Error
GetInconsistentError :: Error
GetOutOfSeqError :: Error
PutBadTokError :: Error
PutOutOfSeqError :: Error
PutTooBigError :: Error
MachineOverflowError :: Error
OutOfMemoryError :: Error
SocketUnacceptedError :: Error
UnconnectedError :: Error
PutEndPacketError :: Error
NextIncompleteCurrentPacketError :: Error
NextUnknownPacketError :: Error
GetEndPacketError :: Error
AbortError :: Error
ClosedError :: Error
InitError :: Error
ArgvError :: Error
ProtocolError :: Error
ModeError :: Error
LaunchError :: Error
RelaunchError :: Error
LaunchSpaceError :: Error
NoParentError :: Error
NameTakenError :: Error
NoListenError :: Error
BadNameError :: Error
BadHostError :: Error
LaunchFailedError :: Error
LaunchNameError :: Error
PutConvertError :: Error
GetConvertError :: Error
PutBadEncodingError :: Error
UnknownError :: Int -> Error
-- | Turns an Integral into the corresponding Error.
mkError :: (Integral a) => a -> Error
-- | An enumeration of MathLink packet types
data Packet
IllegalPacket :: Packet
CallPacket :: Packet
EvaluatePacket :: Packet
ReturnPacket :: Packet
InputNamePacket :: Packet
EnterTextPacket :: Packet
EnterExpressionPacket :: Packet
OutputNamePacket :: Packet
ReturnTextPacket :: Packet
ReturnExpressionPacket :: Packet
DisplayPacket :: Packet
DisplayEndPacket :: Packet
MessagePacket :: Packet
TextPacket :: Packet
InputPacket :: Packet
InputStringPacket :: Packet
MenuPacket :: Packet
SyntaxPacket :: Packet
SuspendPacket :: Packet
ResumePacket :: Packet
BeginDialogPacket :: Packet
EndDialogPacket :: Packet
UserPacket :: Int -> Packet
UnknownPacket :: Int -> Packet
mkPacket :: (Integral a) => a -> Packet
instance Typeable Expression
instance Eq Type
instance Show Type
instance Eq Packet
instance Show Packet
instance Eq Message
instance Show Message
instance Eq Error
instance Show Error
instance Eq Environment
instance Eq Link
instance Monad ML
instance MonadIO ML
instance MonadState State ML
instance MonadReader Config ML
instance MonadError String ML
instance Eq Expression
instance Ord Expression
instance Read Expression
instance Show Expression
instance Data Expression
instance Ord Type
instance Enum Type
instance Ord Packet
instance Enum Packet
instance Ord Message
instance Enum Message
instance Ord Error
instance Enum Error
instance Show Function
module Foreign.MathLink.IO
acquireEnvironment :: IO Environment
acquireLink :: Environment -> [String] -> IO Link
releaseEnvironment :: Environment -> IO ()
releaseLink :: Link -> IO ()
activate :: Link -> IO Bool
flush :: Link -> IO Bool
checkReady :: Link -> IO Bool
getError :: Link -> IO Error
clearError :: Link -> IO Bool
getErrorMessage :: Link -> IO String
convToBool :: (Integral a) => a -> IO Bool
valueOrErrorMsg :: (Integral a) => Link -> b -> a -> IO (Either String b)
getPacket :: Link -> IO Packet
endPacket :: Link -> IO Bool
newPacket :: Link -> IO Bool
getMessage :: Link -> IO (Maybe (Message, Int))
putMessage :: Link -> Message -> IO Bool
checkMessage :: Link -> IO Bool
transferExpression :: Link -> Link -> IO Bool
mlGetNext :: Link -> IO CInt
mlGetType :: Link -> IO CInt
mlTestHead :: Link -> CString -> Ptr CInt -> IO CInt
mlPutInt16 :: Link -> CInt -> IO CInt
mlGetInt16 :: Link -> Ptr CInt -> IO CInt
mlPutInt32 :: Link -> CInt -> IO CInt
mlGetInt32 :: Link -> Ptr CInt -> IO CInt
mlGetInt :: Link -> Ptr CInt -> IO CInt
mlPutReal32 :: Link -> CFloat -> IO CInt
mlGetReal32 :: Link -> Ptr CFloat -> IO CInt
mlPutReal64 :: Link -> CDouble -> IO CInt
mlGetReal64 :: Link -> Ptr CDouble -> IO CInt
mlPutInt16List :: Link -> Ptr CShort -> CInt -> IO CInt
mlGetInt16List :: Link -> Ptr (Ptr CShort) -> Ptr CInt -> IO CInt
mlReleaseInt16List :: Link -> Ptr CShort -> CInt -> IO CInt
mlPutInt32List :: Link -> Ptr CInt -> CInt -> IO CInt
mlGetInt32List :: Link -> Ptr (Ptr CInt) -> Ptr CInt -> IO CInt
mlReleaseInt32List :: Link -> Ptr CInt -> CInt -> IO CInt
mlPutIntList :: Link -> Ptr CInt -> CInt -> IO CInt
mlGetIntList :: Link -> Ptr (Ptr CInt) -> Ptr CInt -> IO CInt
mlReleaseIntList :: Link -> Ptr CInt -> CInt -> IO CInt
mlPutReal32List :: Link -> Ptr CFloat -> CInt -> IO CInt
mlGetReal32List :: Link -> Ptr (Ptr CFloat) -> Ptr CInt -> IO CInt
mlReleaseReal32List :: Link -> Ptr CFloat -> CInt -> IO CInt
mlPutReal64List :: Link -> Ptr CDouble -> CInt -> IO CInt
mlGetReal64List :: Link -> Ptr (Ptr CDouble) -> Ptr CInt -> IO CInt
mlReleaseReal64List :: Link -> Ptr CDouble -> CInt -> IO CInt
mlPutInt16Array :: Link -> Ptr CShort -> Ptr CInt -> Ptr CString -> CInt -> IO CInt
mlGetInt16Array :: Link -> Ptr (Ptr CShort) -> Ptr (Ptr CInt) -> Ptr (Ptr CString) -> Ptr CInt -> IO CInt
mlReleaseInt16Array :: Link -> Ptr CShort -> Ptr CInt -> Ptr CString -> CInt -> IO ()
mlPutInt32Array :: Link -> Ptr CInt -> Ptr CInt -> Ptr CString -> CInt -> IO CInt
mlGetInt32Array :: Link -> Ptr (Ptr CInt) -> Ptr (Ptr CInt) -> Ptr (Ptr CString) -> Ptr CInt -> IO CInt
mlReleaseInt32Array :: Link -> Ptr CInt -> Ptr CInt -> Ptr CString -> CInt -> IO ()
mlPutIntArray :: Link -> Ptr CInt -> Ptr CInt -> Ptr CString -> CInt -> IO CInt
mlGetIntArray :: Link -> Ptr (Ptr CInt) -> Ptr (Ptr CInt) -> Ptr (Ptr CString) -> Ptr CInt -> IO CInt
mlReleaseIntArray :: Link -> Ptr CInt -> Ptr CInt -> Ptr CString -> CInt -> IO ()
mlPutReal32Array :: Link -> Ptr CFloat -> Ptr CInt -> Ptr CString -> CInt -> IO CInt
mlGetReal32Array :: Link -> Ptr (Ptr CFloat) -> Ptr (Ptr CInt) -> Ptr (Ptr CString) -> Ptr CInt -> IO CInt
mlReleaseReal32Array :: Link -> Ptr CFloat -> Ptr CInt -> Ptr CString -> CInt -> IO ()
mlPutReal64Array :: Link -> Ptr CDouble -> Ptr CInt -> Ptr CString -> CInt -> IO CInt
mlGetReal64Array :: Link -> Ptr (Ptr CDouble) -> Ptr (Ptr CInt) -> Ptr (Ptr CString) -> Ptr CInt -> IO CInt
mlReleaseReal64Array :: Link -> Ptr CDouble -> Ptr CInt -> Ptr CString -> CInt -> IO ()
mlPutString :: Link -> CString -> IO CInt
mlGetString :: Link -> Ptr CString -> IO CInt
mlReleaseString :: Link -> CString -> IO ()
mlPutSymbol :: Link -> CString -> IO CInt
mlGetSymbol :: Link -> Ptr CString -> IO CInt
mlReleaseSymbol :: Link -> CString -> IO ()
mlPutFunction :: Link -> CString -> CInt -> IO CInt
mlGetFunction :: Link -> Ptr CString -> Ptr CInt -> IO CInt
module Foreign.MathLink.ML
-- | Runs MathLink, exposing the given list of functions.
runMathLink :: [Function] -> IO ()
-- | Like runMathLink, but explicitly specifies the command line
-- arguments to be passed to MathLink.
runMathLinkWithArgs :: [String] -> [Function] -> IO ()
-- | Sends the given String to Mathematica for evaluation.
--
-- Does not block
evaluate :: String -> ML Bool
-- | Like evaluate, but blocks until the execution is complete.
evaluateString :: String -> ML Bool
-- | Returns the link associated with this thread of execution.
getLink :: ML Link
throwOnError :: (Integral a) => a -> ML ()
boolToError :: Bool -> ML ()
-- | Gets the type of the next expression to be read on the MathLink
-- connection.
getType :: ML Type
putFunctionHead :: String -> Int -> ML ()
getFunctionHead :: ML (String, Int)
-- | Helper for marshaling scalar values to Mathematica.
putScalarWith :: (Link -> b -> IO CInt) -> (a -> b) -> a -> ML ()
-- | Helper for marshaling scalar values from Mathematica.
getScalarWith :: (Storable a) => (Link -> Ptr a -> IO CInt) -> (a -> b) -> ML b
-- | Helper for marshaling Strings to Mathematica.
putStringWith :: (Link -> CString -> IO CInt) -> String -> ML ()
-- | Helper for marshaling Strings from Mathematica.
getStringWith :: (Link -> Ptr CString -> IO CInt) -> (Link -> CString -> IO ()) -> ML String
withLink0 :: (Link -> IO a) -> ML a
withLink1 :: (Link -> a -> IO b) -> (a -> ML b)
withLink2 :: (Link -> a -> b -> IO c) -> (a -> b -> ML c)
withLink3 :: (Link -> a -> b -> c -> IO d) -> (a -> b -> c -> ML d)
withLink4 :: (Link -> a -> b -> c -> d -> IO e) -> (a -> b -> c -> d -> ML e)
instance Expressible Expression
module Foreign.MathLink.Expressible
putString :: String -> ML ()
getString :: ML String
putInt16List :: [Int16] -> ML ()
getInt16List :: ML [Int16]
putInt32List :: [Int32] -> ML ()
getInt32List :: ML [Int32]
putIntList :: [Int] -> ML ()
getIntList :: ML [Int]
putReal32List :: [Float] -> ML ()
getReal32List :: ML [Float]
putReal64List :: [Double] -> ML ()
getReal64List :: ML [Double]
instance (Dimensional ix) => Expressible (UArray ix Double)
instance (Dimensional ix) => Expressible (UArray ix Float)
instance (Dimensional ix) => Expressible (UArray ix Int)
instance (Dimensional ix) => Expressible (UArray ix Int32)
instance (Dimensional ix) => Expressible (UArray ix Int16)
instance Dimensional (Int, Int, Int, Int, Int)
instance Dimensional (Int, Int, Int, Int)
instance Dimensional (Int, Int, Int)
instance Dimensional (Int, Int)
instance Dimensional Int
instance (Expressible e) => Expressible [e]
instance (Expressible e1, Expressible e2, Expressible e3, Expressible e4, Expressible e5, Expressible e6, Expressible e7) => Expressible (e1, e2, e3, e4, e5, e6, e7)
instance (Expressible e1, Expressible e2, Expressible e3, Expressible e4, Expressible e5, Expressible e6) => Expressible (e1, e2, e3, e4, e5, e6)
instance (Expressible e1, Expressible e2, Expressible e3, Expressible e4, Expressible e5) => Expressible (e1, e2, e3, e4, e5)
instance (Expressible e1, Expressible e2, Expressible e3, Expressible e4) => Expressible (e1, e2, e3, e4)
instance (Expressible e1, Expressible e2, Expressible e3) => Expressible (e1, e2, e3)
instance (Expressible e1, Expressible e2) => Expressible (e1, e2)
instance Expressible Double
instance Expressible Float
instance Expressible Int
instance Expressible Int32
instance Expressible Int16
instance Expressible Char
-- | A Haskell interface to Mathematica's MathLink.
module Foreign.MathLink