erlang-0.1: FFI interface to Erlang.

MaintainerEric Sessoms <>




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.


Low-level communication with the Erlang Port-Mapper Daemon.

epmdGetNames :: IO [String]Source

Return the names and addresses of all registered Erlang nodes.

epmdGetPort :: String -> IO IntSource

Return the port address of a named Erlang node.

epmdGetPortR4 :: String -> IO (Int, Int, Int, Int, Int, String, String)Source

Returns (port, nodeType, protocol, vsnMax, vsnMin, name, extra)

High-level communication.

genCall :: Erlang a => MBox -> Node -> Pid -> a -> IO ErlTypeSource

gen_server:call(Pid, Msg)

genCast :: Erlang a => MBox -> Node -> Pid -> a -> IO ()Source

gen_server:cast(Pid, Msg)

rpcCall :: MBox -> Node -> String -> String -> [ErlType] -> IO ErlTypeSource

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.

Represents a Haskell node (program).

data Self Source

Represents a Haskell node. There should be one of these per process.

createSelf :: String -> IO SelfSource

Instantiate a Haskell node. This initializes the FFI.

Represents a Haskell process (thread).

data MBox Source

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 MBoxSource

Create a new process on the Haskell side. Usually corresponds to a thread but doesn't need to.

mboxRef :: MBox -> IO ErlTypeSource

Return a new unique object reference.

mboxSelf :: MBox -> ErlTypeSource

Return the PID of the given mailbox.

Represents Erlang nodes and processes.

type Node = StringSource

The name of an Erlang node on the network.

type Pid = Either ErlType StringSource

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/from Erlang.

mboxRecv :: MBox -> IO ErlTypeSource

Receive the next message addressed to this mailbox.

mboxRecv' :: MBox -> ErlType -> IO ErlTypeSource

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

{Node, Pid} ! Msg.

Native Erlang data types.

Haskell representation.

Conversion between native Haskell types and ErlType.

class Erlang a whereSource


Erlang Bool 
Erlang Int 
Erlang Integer 
Erlang String 
Erlang ErlType 
Erlang a => Erlang [a] 
Erlang [ErlType] 
(Erlang a, Erlang b) => Erlang (a, b) 
(Erlang a, Erlang b, Erlang c) => Erlang (a, b, c) 
(Erlang a, Erlang b, Erlang c, Erlang d) => Erlang (a, b, c, d) 
(Erlang a, Erlang b, Erlang c, Erlang d, Erlang e) => Erlang (a, b, c, d, e) 

Easy type-safe access to tuple members.

nth :: Erlang a => Int -> ErlType -> aSource

Internal packing functions.

Miscellaneous utilities.

erlangTimeToSeconds :: Integral a => ErlType -> aSource

Convert a tuple (from erlang:now()) to seconds from Jan 1, 1970.

secondsToErlangTime :: Integral a => a -> ErlTypeSource

Convert seconds to an Erlang tuple representing time.