| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
AsyncRattus.Channels
Description
This module is meant for library authors that want to build APIs for interacting with asynchronous resources, e.g. a GUI framework.
Synopsis
- getInput :: IO (Box (O a) :* (a -> IO ()))
- setOutput :: Producer p a => p -> (a -> IO ()) -> IO ()
- mkInput :: Producer p a => p -> IO (Box (O a))
- startEventLoop :: IO ()
- timer :: Int -> Box (O ())
- class Producer p a | p -> a where
- getCurrent :: p -> Maybe' a
- getNext :: p -> (forall q. Producer q a => O q -> b) -> b
Documentation
getInput :: IO (Box (O a) :* (a -> IO ())) Source #
This function can be used to implement input signals. It returns
a boxed delayed computation s and a callback function cb. The
signal mkSig s will produce a new value v whenever the callback
function cb is called with argument v.
setOutput :: Producer p a => p -> (a -> IO ()) -> IO () Source #
This function can be used to produces outputs. Given a signal s
and function f, the call setOutput s f registers f as a
callback function that is called with argument v whenever the
signal produces a new value v. For this function to work,
startEventLoop must be called.
startEventLoop :: IO () Source #
In order for setOutput to work, this IO action must be invoked.
class Producer p a | p -> a where Source #
A type p satisfying Producer p a is essentially a signal that
produces values of type a but it might not produce such values at
each tick.
Methods
getCurrent :: p -> Maybe' a Source #
Get the current value of the producer if any.
getNext :: p -> (forall q. Producer q a => O q -> b) -> b Source #
Get the next state of the producer. Morally, the type of this method should be
getNext :: p -> (exists q. Producer q a => O q)
We encode the existential type using continuation-passing style.