AsyncRattus-0.2.0.1: An asynchronous modal FRP language
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

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.

mkInput :: Producer p a => p -> IO (Box (O a)) Source #

This function is essentially the composition of getInput and setOutput. It turns any producer into a signal.

startEventLoop :: IO () Source #

In order for setOutput to work, this IO action must be invoked.

timer :: Int -> Box (O ()) Source #

timer n produces a delayed computation that ticks every n milliseconds. In particular mkSig (timer n) is a signal that produces a new value every milliseconds.

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.

Instances

Instances details
Producer p a => Producer (F p) a Source # 
Instance details

Defined in AsyncRattus.Future

Methods

getCurrent :: F p -> Maybe' a Source #

getNext :: F p -> (forall q. Producer q a => O q -> b) -> b Source #

Producer (SigF a) a Source # 
Instance details

Defined in AsyncRattus.Future

Methods

getCurrent :: SigF a -> Maybe' a Source #

getNext :: SigF a -> (forall q. Producer q a => O q -> b) -> b Source #

Producer p a => Producer (Box p) a Source # 
Instance details

Defined in AsyncRattus.Channels

Methods

getCurrent :: Box p -> Maybe' a Source #

getNext :: Box p -> (forall q. Producer q a => O q -> b) -> b Source #

Producer p a => Producer (O p) a Source # 
Instance details

Defined in AsyncRattus.Channels

Methods

getCurrent :: O p -> Maybe' a Source #

getNext :: O p -> (forall q. Producer q a => O q -> b) -> b Source #

Producer (Sig a) a Source # 
Instance details

Defined in AsyncRattus.Signal

Methods

getCurrent :: Sig a -> Maybe' a Source #

getNext :: Sig a -> (forall q. Producer q a => O q -> b) -> b Source #