Copyright | (c) Eric Sessoms, 2008 (c) Artúr Poór, 2015 |
---|---|
License | GPL3 |
Maintainer | gombocarti@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
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.
- epmdGetNames :: IO [String]
- epmdGetPort :: Node -> IO Int
- 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 ()
- type Name = String
- type Ip = String
- data Node
- erlConnect :: String -> Node -> IO (ErlSend, ErlRecv)
- toNetwork :: Int -> Integer -> [Word8]
- genCall :: Erlang a => MBox -> Node -> Pid -> a -> IO ErlType
- genCast :: Erlang a => MBox -> Node -> Pid -> a -> IO ()
- rpcCall :: MBox -> Node -> String -> String -> [ErlType] -> IO ErlType
- 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
- data Self
- createSelf :: String -> IO Self
- data MBox
- createMBox :: Self -> IO MBox
- mboxRef :: MBox -> IO ErlType
- mboxSelf :: MBox -> ErlType
- type Pid = Either ErlType String
- mboxRecv :: MBox -> IO ErlType
- mboxRecv' :: MBox -> ErlType -> IO ErlType
- mboxSend :: Erlang a => MBox -> Node -> Pid -> a -> IO ()
- data ErlType
- class Erlang a where
- toErlang :: a -> ErlType
- fromErlang :: 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
- erlangTimeToSeconds :: Integral a => ErlType -> a
- secondsToErlangTime :: Integral a => a -> ErlType
Low-level communication with the Erlang Port-Mapper Daemon
epmdGetNames :: IO [String] Source
Return the names and addresses of registered local Erlang nodes.
epmdGetPort :: Node -> IO Int Source
Return the port address of a named Erlang node.
epmdGetPortR4 :: String -> String -> IO (Int, Int, Int, Int, Int, String, String) Source
Returns (port, nodeType, protocol, vsnMax, vsnMin, name, extra)
Representation of Erlang nodes
Representation of an Erlang node on the network.
High-level communication
rpcCall :: MBox -> Node -> String -> String -> [ErlType] -> IO ErlType Source
rpc:call(Node, Module, Function, Arguments)
rpcCast :: MBox -> Node -> String -> String -> [ErlType] -> IO () Source
rpc:cast(Node, Module, Function, Arguments)
Mnesia database methods
Low-level communication
Representation of a Haskell node (program)
createSelf :: String -> IO Self Source
Instantiate a Haskell node. This initializes the FFI.
Representation of a Haskell process (thread)
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.
createMBox :: Self -> IO MBox Source
Create a new process on the Haskell side. Usually corresponds to a thread but doesn't need to.
Representation of Erlang nodes and processes
type Pid = Either ErlType String Source
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).
Communication to and from Erlang
mboxRecv' :: MBox -> ErlType -> IO ErlType Source
Receive a reply message. That is, looks for the next message identified by the given reference.
mboxSend :: Erlang a => MBox -> Node -> Pid -> a -> IO () Source
Send an arbitrary message to the specified node and process. In Erlang equivalent to
{Node, Pid} ! Msg.
Native Erlang data types
Conversion between native Haskell types and ErlType
Erlang Bool Source | |
Erlang Int Source | |
Erlang Integer Source | |
Erlang String Source | |
Erlang ErlType Source | |
Erlang Node Source | |
Erlang a => Erlang [a] Source | |
Erlang [ErlType] Source | |
(Erlang a, Erlang b) => Erlang (a, b) Source | |
(Erlang a, Erlang b, Erlang c) => Erlang (a, b, c) Source | |
(Erlang a, Erlang b, Erlang c, Erlang d) => Erlang (a, b, c, d) Source | |
(Erlang a, Erlang b, Erlang c, Erlang d, Erlang e) => Erlang (a, b, c, d, e) Source |
Easy type-safe access to tuple members
Internal packing functions
Miscellaneous utilities
erlangTimeToSeconds :: Integral a => ErlType -> a Source
Convert a tuple (from erlang:now()) to seconds from Jan 1, 1970.
secondsToErlangTime :: Integral a => a -> ErlType Source
Convert seconds to an Erlang tuple representing time.