-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Lightweight Erlang-style actors for Haskell.
--
-- Hactor is a library which aims to provide lightweight Erlang-style
-- actors for Haskell.
@package hactor
@version 1.0.0.0
-- | This module implements Erlang-style actors (what Erlang calls
-- processes).
--
-- @
module Control.Concurrent.Actor
-- | An ActorHandle acts as a reference to a specific actor.
data ActorMessage msg => ActorHandle msg
-- | The ActorMessage class must be implemented by any type that
-- will be sent as a message to actors. Any given type of actor will have
-- one ActorMessage type that is sent to that actor. This ensures
-- type safety. Currently this is simply a dummy class with nothing in
-- it, but things may be added in the future.
class ActorMessage msg
-- | The base actor monad.
type ActorM msg = ReaderT (ActorContext msg) IO
-- | Sends a message to the given actor handle. This is secretly just
-- sendIO lifted into an actor monad.
send :: (ActorMessage msg, ActorMessage msg') => ActorHandle msg -> msg -> ActorM msg' ()
-- | Sends a message to the given actor handle from within the IO monad.
sendIO :: ActorMessage msg => ActorHandle msg -> msg -> IO ()
-- | Reads a message from the actor's mail box. If there are no messages,
-- blocks until one is received. If you don't want this, use
-- receiveMaybe instead.
receive :: ActorMessage msg => ActorM msg (msg)
-- | Reads a message from the actor's mail box. If there are no messages,
-- returns Nothing.
receiveMaybe :: ActorMessage msg => ActorM msg (Maybe msg)
-- | Spawns the given actor on another thread and returns a handle to it.
spawnActor :: ActorMessage msg => ActorM msg () -> IO (ActorHandle msg)
-- | Runs the given actor on the current thread. This function effectively
-- turns the current thread into the actor's thread. Obviously, this
-- means that this function will block until the actor exits. You
-- probably want to use this for your "main" actor.
runActor :: ActorMessage msg => ActorM msg () -> IO ()
-- | Gets a handle to the current actor.
self :: ActorMessage msg => ActorM msg (ActorHandle msg)
-- | Gets the thread ID for the given actor handle.
actorThread :: ActorMessage msg => ActorHandle msg -> ThreadId
instance ActorMessage ()