Source codeContentsIndex
Events
Synopsis
data Result
= Immediate
| Awaiting (IO ())
| AwaitingAlways (IO ())
newtype Event a = Event (Toggle -> (IO a -> IO ()) -> IO Result)
class HasEvent eventType where
toEvent :: eventType a -> Event a
never :: Event a
always :: IO a -> Event a
sync :: Event a -> IO a
poll :: Event a -> IO (Maybe a)
(>>>=) :: Event a -> (a -> IO b) -> Event b
(>>>) :: Event a -> IO b -> Event b
(+>) :: Event a -> Event a -> Event a
choose :: [Event a] -> Event a
tryEV :: Event a -> Event (Either IOError a)
computeEvent :: IO (Event a) -> Event a
wrapAbort :: IO (Event a, IO ()) -> Event a
noWait :: Event a -> Event ()
class HasSend chan where
send :: chan a -> a -> Event ()
class HasReceive chan where
receive :: chan a -> Event a
sendIO :: (HasSend chan) => chan a -> a -> IO ()
receiveIO :: (HasReceive chan) => chan a -> IO a
allowWhile :: Event () -> Event a -> Event a
data Request a b = Request (a -> IO (Event b, IO ()))
request :: Request a b -> a -> IO b
doRequest :: Request a b -> a -> IO (Event b, IO ())
spawnEvent :: Event () -> IO (IO ())
getAllQueued :: Event a -> IO [a]
thenGetEvent :: Event a -> (a -> Event b) -> Event b
thenEvent :: Event a -> Event b -> Event b
doneEvent :: a -> Event a
syncNoWait :: Event a -> IO ()
Documentation
data Result
Constructors
Immediate
Awaiting (IO ())
AwaitingAlways (IO ())
newtype Event a
Constructors
Event (Toggle -> (IO a -> IO ()) -> IO Result)
Instances
HasEvent Event
Monad Event
class HasEvent eventType where
HasEvent represents those event-like things which can be converted to an event.
Methods
toEvent :: eventType a -> Event a
Instances
HasEvent Event
(Guard guard) => HasEvent (GuardedEvent guard)
never :: Event a
always :: IO a -> Event a
The event that always happens, immediately
sync :: Event a -> IO a
Synchronise on an event, waiting on it until it happens, then returning the attached value.
poll :: Event a -> IO (Maybe a)
Synchronise on an event, but return immediately with Nothing if it can't be satisfied at once.
(>>>=) :: Event a -> (a -> IO b) -> Event b
Attach an action to be done after the event occurs.
(>>>) :: Event a -> IO b -> Event b
Attach an action to be done after the event occurs.
(+>) :: Event a -> Event a -> Event a
Choose between two events. The first one takes priority.
choose :: [Event a] -> Event a
Choose between a list of events.
tryEV :: Event a -> Event (Either IOError a)
Catch an error if it occurs during an action attached to an event.
computeEvent :: IO (Event a) -> Event a
Construct a new event using an action which is called at each synchronisation
wrapAbort :: IO (Event a, IO ()) -> Event a
When we synchronise on wrapAbort preAction preAction is evaluated to yield (event,postAction). Then exactly one of the following: (1) thr event is satisfied, and postAction is not done. (2) some other event in this synchronisation is satisfied (so this one isn't), and postAction is done. (3) no event is satisfied (and so we will deadlock).
noWait :: Event a -> Event ()
Turns an event into one which is always satisfied at once but registers the value to be done later. WARNING - only to be used with events without actions attached, as any actions will not get done. noWait is typically used with send events, where we don't want to wait for someone to pick up the value.
class HasSend chan where
HasSend represents things like channels on which we can send values
Methods
send :: chan a -> a -> Event ()
Instances
HasSend Channel
HasSend (GuardedChannel guard)
class HasReceive chan where
HasReceive represents things like channels from which we can take values.
Methods
receive :: chan a -> Event a
Instances
HasReceive Channel
(Guard guard) => HasReceive (GuardedChannel guard)
sendIO :: (HasSend chan) => chan a -> a -> IO ()
Send a value along a channel (as an IO action)
receiveIO :: (HasReceive chan) => chan a -> IO a
Get a value from a channel (as an IO action)
allowWhile :: Event () -> Event a -> Event a
allowWhile event1 event2 waits for event2, while handling event1.
data Request a b
Constructors
Request (a -> IO (Event b, IO ()))
request :: Request a b -> a -> IO b
doRequest :: Request a b -> a -> IO (Event b, IO ())
spawnEvent :: Event () -> IO (IO ())
Synchronise on an event in a different thread.
getAllQueued :: Event a -> IO [a]
get all we can get from the event without waiting.
thenGetEvent :: Event a -> (a -> Event b) -> Event b
thenEvent :: Event a -> Event b -> Event b
doneEvent :: a -> Event a
syncNoWait :: Event a -> IO ()
Register an event as synchronised but don't wait for it to complete. WARNING - only to be used with events without actions attached, as any actions will not get done. noWait is typically used with send events, where we don't want to wait for someone to pick up the value. synchronise on something without waiting
Produced by Haddock version 0.3