-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | FFI interface to Erlang. -- -- Speaks the Erlang network protocol and impersonates an Erlang node on -- the network. Fully capable of bi-directional communication with -- Erlang. Erlang types are, as far as reasonable, mapped to Haskell -- types. Messages to Erlang are just function calls in Haskell, and -- messages from Erlang are delivered to MVars. @package erlang @version 0.2 -- | Speaks the Erlang network protocol and impersonates an Erlang node on -- the network. Fully capable of bi-directional communication with -- Erlang. Erlang types are, as far as reasonable, mapped to Haskell -- types. Messages to Erlang are just function calls in Haskell, and -- messages from Erlang are delivered to MVars. module Foreign.Erlang -- | Return the names and addresses of registered local Erlang nodes. epmdGetNames :: IO [String] -- | Return the port address of a named Erlang node. epmdGetPort :: Node -> IO Int -- | Returns (port, nodeType, protocol, vsnMax, vsnMin, name, extra) epmdGetPortR4 :: String -> String -> IO (Int, Int, Int, Int, Int, String, String) type ErlRecv = IO (Maybe ErlType, Maybe ErlType) type ErlSend = (Maybe ErlType, Maybe ErlType) -> IO () -- | Name of an Erlang node. type Name = String -- | Ip address of a remote Erlang node. type Ip = String -- | Representation of an Erlang node on the network. data Node -- | Local Erlang node. Short :: Name -> Node -- | Remote Erlang node. Long :: Name -> Ip -> Node erlConnect :: String -> Node -> IO (ErlSend, ErlRecv) toNetwork :: Int -> Integer -> [Word8] -- | gen_server:call(Pid, Msg) genCall :: Erlang a => MBox -> Node -> Pid -> a -> IO ErlType -- | gen_server:cast(Pid, Msg) genCast :: Erlang a => MBox -> Node -> Pid -> a -> IO () -- | rpc:call(Node, Module, Function, Arguments) rpcCall :: MBox -> Node -> String -> String -> [ErlType] -> IO ErlType -- | rpc:cast(Node, Module, Function, Arguments) rpcCast :: MBox -> Node -> String -> String -> [ErlType] -> IO () backup :: MBox -> Node -> String -> IO ErlType dirtyAllKeys :: MBox -> Node -> String -> IO ErlType dirtyFirst :: MBox -> Node -> String -> IO ErlType dirtyNext :: MBox -> Node -> String -> ErlType -> IO ErlType dirtyLast :: MBox -> Node -> String -> IO ErlType dirtyPrev :: MBox -> Node -> String -> ErlType -> IO ErlType dirtyMatchObject :: MBox -> Node -> ErlType -> IO ErlType dirtyRead :: MBox -> Node -> String -> ErlType -> IO ErlType dirtySelect :: MBox -> Node -> String -> ErlType -> IO ErlType -- | Represents a Haskell node. There should be one of these per process. data Self -- | Instantiate a Haskell node. This initializes the FFI. createSelf :: String -> IO Self -- | Haskell threads don't natively have Erlang process IDs. Instead, we -- use a mailbox abstraction that we can assign PIDs to for communication -- with Erlang. data MBox -- | Create a new process on the Haskell side. Usually corresponds to a -- thread but doesn't need to. createMBox :: Self -> IO MBox -- | Return a new unique object reference. mboxRef :: MBox -> IO ErlType -- | Return the PID of the given mailbox. mboxSelf :: MBox -> ErlType -- | Represents a foreign (Erlang) process. A process can be identified -- either by its low-level ID (Left pid) or by its registered name (Right -- name). type Pid = Either ErlType String -- | Receive the next message addressed to this mailbox. mboxRecv :: MBox -> IO ErlType -- | Receive a reply message. That is, looks for the next message -- identified by the given reference. mboxRecv' :: MBox -> ErlType -> IO ErlType -- | Send an arbitrary message to the specified node and process. In Erlang -- equivalent to -- --
--   {Node, Pid} ! Msg.
--   
mboxSend :: Erlang a => MBox -> Node -> Pid -> a -> IO () data ErlType ErlNull :: ErlType ErlInt :: Int -> ErlType ErlBigInt :: Integer -> ErlType ErlString :: String -> ErlType ErlAtom :: String -> ErlType ErlBinary :: [Word8] -> ErlType ErlList :: [ErlType] -> ErlType ErlTuple :: [ErlType] -> ErlType ErlPid :: ErlType -> Int -> Int -> Int -> ErlType ErlPort :: ErlType -> Int -> Int -> ErlType ErlRef :: ErlType -> Int -> Int -> ErlType ErlNewRef :: ErlType -> Int -> [Word8] -> ErlType class Erlang a toErlang :: Erlang a => a -> ErlType fromErlang :: Erlang a => ErlType -> a nth :: Erlang a => Int -> ErlType -> a getA :: Int -> Get String getC :: Get Int getErl :: Get ErlType getN :: Get Int geta :: Int -> Get [Word8] getn :: Get Int putA :: String -> Builder putC :: Integral a => a -> Builder putErl :: ErlType -> Builder putN :: Integral a => a -> Builder puta :: [Word8] -> Builder putn :: Integral a => a -> Builder tag :: Char -> Builder -- | Convert a tuple (from erlang:now()) to seconds from Jan 1, 1970. erlangTimeToSeconds :: Integral a => ErlType -> a -- | Convert seconds to an Erlang tuple representing time. secondsToErlangTime :: Integral a => a -> ErlType