-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | BERT implementation -- -- Implements the BERT serialization and RPC protocols described at -- http://bert-rpc.org/. @package bert @version 1.2.2.2 -- | The Term type. module Data.BERT.Types -- | A single BERT term. data Term IntTerm :: Int -> Term FloatTerm :: Float -> Term AtomTerm :: String -> Term TupleTerm :: [Term] -> Term BytelistTerm :: ByteString -> Term ListTerm :: [Term] -> Term BinaryTerm :: ByteString -> Term BigintTerm :: Integer -> Term BigbigintTerm :: Integer -> Term NilTerm :: Term BoolTerm :: Bool -> Term DictionaryTerm :: [(Term, Term)] -> Term TimeTerm :: UTCTime -> Term RegexTerm :: String -> [String] -> Term instance Eq Term instance Ord Term instance Show Term instance Read Term -- | Parse (simple) BERTs. module Data.BERT.Parser -- | Parse a simple BERT (erlang) term from a string in the erlang grammar. -- Does not attempt to decompose complex terms. parseTerm :: String -> Either ParseError Term -- | Define BERT terms their binary encoding & decoding and a typeclass -- for converting Haskell values to BERT terms and back. -- -- We define a number of convenient instances for BERT. Users will -- probably want to define their own instances for composite types. module Data.BERT.Term class BERT a showBERT :: BERT a => a -> Term readBERT :: BERT a => Term -> (Either String a) showTerm :: Term -> String -- | Parse a simple BERT (erlang) term from a string in the erlang grammar. -- Does not attempt to decompose complex terms. parseTerm :: String -> Either ParseError Term instance [overlap ok] Binary Term instance [overlap ok] (Ord k, BERT k, BERT v) => BERT (Map k v) instance [overlap ok] (BERT a, BERT b, BERT c, BERT d) => BERT (a, b, c, d) instance [overlap ok] (BERT a, BERT b, BERT c) => BERT (a, b, c) instance [overlap ok] (BERT a, BERT b) => BERT (a, b) instance [overlap ok] BERT a => BERT [a] instance [overlap ok] BERT ByteString instance [overlap ok] BERT String instance [overlap ok] BERT Float instance [overlap ok] BERT Integer instance [overlap ok] BERT Bool instance [overlap ok] BERT Int instance [overlap ok] BERT Term -- | BERP (BERT packets) support. module Data.BERT.Packet -- | A single BERP. Little more than a wrapper for a term. data Packet Packet :: Term -> Packet fromPacket :: Packet -> Term instance Show Packet instance Ord Packet instance Eq Packet instance Binary Packet -- | BERT (Erlang terms) implementation. See http://bert-rpc.org/ -- and http://erlang.org/doc/apps/erts/erl_ext_dist.html for more -- details. module Data.BERT -- | Underlying transport abstraction module Network.BERT.Transport -- | The class for transports class Transport t runSession :: Transport t => t -> TransportM a -> IO a closeConnection :: Transport t => t -> IO () class Transport (ServerTransport s) => Server s where type family ServerTransport s runServer :: Server s => s -> (ServerTransport s -> IO ()) -> IO () cleanup :: Server s => s -> IO () -- | The transport monad allows receiving packets through the conduit, and -- sending functions via the provided SendPacketFn type TransportM = ReaderT SendPacketFn (ConduitM Packet Void IO) -- | A function to send packets to the peer type SendPacketFn = Packet -> IO () -- | Send a term sendt :: Term -> TransportM () -- | Receive a term recvt :: TransportM (Maybe Term) -- | Execute an action for every incoming term, until the connection is -- closed recvtForever :: (Term -> TransportM a) -> TransportM () -- | The TCP transport data TCP TCP :: !Socket -> TCP -- | The socket used for communication. -- -- The connection is assumed to be already established when this -- structure is passed in. getTcpSocket :: TCP -> !Socket -- | Establish a connection to the TCP server and return the resulting -- transport. It can be used to make multiple requests. tcpClient :: HostName -> PortNumber -> IO TCP -- | The TCP server data TCPServer TCPServer :: !Socket -> TCPServer -- | The listening socket. Assumed to be bound but not listening yet. getTcpListenSocket :: TCPServer -> !Socket -- | A simple TCPServer constructor, listens on all local -- interfaces. -- -- If you want to bind only to some of the interfaces, create the socket -- manually using the functions from Network.Socket. tcpServer :: PortNumber -> IO TCPServer -- | A simple address resolver resolve :: HostName -> IO HostAddress instance Server TCPServer instance Transport TCP -- | BERT-RPC client (http://bert-rpc.org/). This implements the -- client RPC call logic. module Network.BERT.Client -- | Call the {mod, func, args} synchronously on the endpoint -- defined by transport, returning the results of the call or an -- error. call :: (BERT a, BERT b, Transport t) => t -> String -> String -> [a] -> Call b -- | Establish a connection to the TCP server and return the resulting -- transport. It can be used to make multiple requests. tcpClient :: HostName -> PortNumber -> IO TCP -- | Convenience type for call type Call a = IO (Either Error a) data Error ClientError :: String -> Error ServerError :: Term -> Error instance Show Error instance Ord Error instance Eq Error -- | BERT-RPC server (http://bert-rpc.org/). This implements the -- client RPC call/reply logic. Only synchronous requests are supported -- at this time. module Network.BERT.Server -- | Serve from the given transport (forever), handling each request with -- the given dispatch function in a new thread. serve :: Server s => s -> (String -> String -> [Term] -> IO DispatchResult) -> IO () data DispatchResult Success :: Term -> DispatchResult NoSuchModule :: DispatchResult NoSuchFunction :: DispatchResult Undesignated :: String -> DispatchResult -- | A simple TCPServer constructor, listens on all local -- interfaces. -- -- If you want to bind only to some of the interfaces, create the socket -- manually using the functions from Network.Socket. tcpServer :: PortNumber -> IO TCPServer instance Eq DispatchResult instance Show DispatchResult instance Ord DispatchResult -- | BERT-RPC client (http://bert-rpc.org/). See -- Network.BERT.Client and Network.BERT.Server for more -- details. module Network.BERT