Not exactly the FRP model, but rather a model of a large application with heterogenous data and many inputs and outputs. An application is in its essence a collection of widgets and behaviours and events with a bus. The bus holds events and manages the event timeline. Behaviours and widgets are continuous. Widgets applied to the bus make insertions and never deletions. Behaviours applied to the bus make insertions and deletions.
Behaviours are composable using combinators that set one Behaviour as either behind, in front, or beside another behaviour on the bus. The in front and behind combinators establish that the behaviour behind the others sees the results of the other behaviours' application to the bus. The beside combinator says that the combinators see the same bus.
- data BusIterationChanges
- data TimeSpan
- = Persistent
- | Time DiffTime
- | Iterations Int
- seconds :: Integer -> TimeSpan
- minutes :: Integer -> TimeSpan
- hours :: Integer -> TimeSpan
- days :: Integer -> TimeSpan
- once :: TimeSpan
- data Diff a
- data EData a
- = EString String
- | EByteString ByteString
- | EByteStringL [ByteString]
- | ELByteString ByteString
- | ELByteStringL [ByteString]
- | EChar Char
- | EDouble Double
- | EInt Int
- | EBool Bool
- | EStringL [String]
- | EDoubleL [Double]
- | EIntL [Int]
- | EBoolL [Bool]
- | EOther a
- | EAssoc (String, EData a)
- | EAssocL [(String, EData a)]
- | EOtherL [a]
- safeShow :: Maybe Int -> EData a -> String
- data Event a = Event {}
- data Bus a = Bus {}
- eventsByName :: String -> Bus a -> Set (Event a)
- eventsBySource :: String -> Bus a -> Set (Event a)
- eventsByGroup :: String -> Bus a -> Set (Event a)
- eventByQName :: String -> String -> String -> Bus a -> Maybe (Event a)
- emptyBus :: Bus a
- addEvent :: Event a -> Bus a -> Bus a
- type Widget a = MVar (Bus a) -> IO ()
- type Future a = IO (Bus a, MVar [Diff a])
- future :: Bus a -> IO [Diff a] -> Future a
- type Behaviour a = Bus a -> Future a
- passthrough :: Behaviour a
- (<~<) :: Behaviour a -> Behaviour a -> Behaviour a
- (>~>) :: Behaviour a -> Behaviour a -> Behaviour a
- (|~|) :: Behaviour a -> Behaviour a -> Behaviour a
- bus :: [Widget a] -> IO b -> Behaviour a -> IO ()
- busIteration :: MVar (Bus a) -> Behaviour a -> IO ()
- produce :: String -> String -> String -> TimeSpan -> a -> IO (Diff a)
- produce' :: String -> String -> String -> TimeSpan -> a -> MVar (Bus a) -> IO ()
- consumeNamedEventsCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future a
- consumeNamedEvents :: String -> Behaviour a
- consumeEventGroup :: String -> Behaviour a
- consumeEventsFromSource :: String -> Behaviour a
- consumeFullyQualifiedEvent :: String -> String -> String -> Behaviour a
- modifyEventData :: Event a -> (a -> a) -> [Diff a]
- modifyEvent :: Event a -> (Event a -> Event a) -> [Diff a]
- consumeNamedEventsWith :: Bus a -> String -> (Event a -> IO [Diff a]) -> Future a
- consumeEventGroupCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future a
- consumeEventGroupWith :: Bus a -> String -> (Event a -> IO [Diff a]) -> Future a
- consumeEventsFromSourceCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future a
- consumeEventsFromSourceWith :: Bus a -> String -> (Event a -> IO [Diff a]) -> Future a
- consumeFullyQualifiedEventWith :: Bus a -> String -> String -> String -> (Event a -> IO [Diff a]) -> Future a
- pollNamedEventsCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future a
- pollNamedEventsWith :: Bus a -> String -> (Event a -> IO [Diff a]) -> Future a
- pollEventGroupCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future a
- pollEventGroupWith :: Bus a -> String -> (Event a -> IO [Diff a]) -> Future a
- pollEventsFromSourceCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future a
- pollEventsFromSourceWith :: Bus a -> String -> (Event a -> IO [Diff a]) -> Future a
- pollFullyQualifiedEventWith :: Bus a -> String -> String -> String -> (Event a -> IO [Diff a]) -> Future a
- pollAllEventsWith :: Bus a -> (Event a -> IO [Diff a]) -> Future a
- pollAllEventsCollectivelyWith :: Bus a -> (Set (Event a) -> IO [Diff a]) -> Future a
Documentation
Defines the amount of time that an event exists.
Persistent | The event exists forever |
Time DiffTime | The event exists for a specified amount of real time |
Iterations Int | The event exists for a certain number of samples of time from its inception. |
Defines time in terms of the differences from time t0 to the next instant. This is the type returned by Behaviours to describe time directly after the Behaviour.
Defines the data attachable to events.
EString String | |
EByteString ByteString | |
EByteStringL [ByteString] | |
ELByteString ByteString | |
ELByteStringL [ByteString] | |
EChar Char | |
EDouble Double | |
EInt Int | |
EBool Bool | |
EStringL [String] | |
EDoubleL [Double] | |
EIntL [Int] | |
EBoolL [Bool] | |
EOther a | |
EAssoc (String, EData a) | |
EAssocL [(String, EData a)] | |
EOtherL [a] |
safeShow :: Maybe Int -> EData a -> StringSource
Show without risking running into an unshowable type.
An discrete event in time
Event | The time of the event's inception. |
|
The type of a discrete sample of continuous time.
Bus | |
|
type Widget a = MVar (Bus a) -> IO ()Source
The type of widgets. A widget is an input-only way to assign Events to time. A mouse is a widget. A keyboard is a widget. A webcam is a widget, and so on.
type Future a = IO (Bus a, MVar [Diff a])Source
The type of future events.. A behaviour doesn't know about the time that it assigns events, only that they exist at some point after the time that the Behaviour sampled.
type Behaviour a = Bus a -> Future aSource
Obtain the final value of a Future. Blocks until the value is available
The type of a Behaviour. A behaviour maps the bus to a list of differences to apply to the bus before the next Behaviour's sample of time.
passthrough :: Behaviour aSource
The null Behaviour. Samples the bus and adds and deletes nothing.
(<~<) :: Behaviour a -> Behaviour a -> Behaviour aSource
the in front of behaviour combinator. behaviour 1 is in front of behaviour 0, so behavour 0 will see the bus filtered through behaviour 1
(>~>) :: Behaviour a -> Behaviour a -> Behaviour aSource
the behind behaviour combinator. behaviour 0 is behind behaviour 1, so behaviour 0 will see the bus filtered through behaviour 1
(|~|) :: Behaviour a -> Behaviour a -> Behaviour aSource
the beside behaviour combinator. All behaviours that are side-by-side see the same bus.
bus :: [Widget a] -> IO b -> Behaviour a -> IO ()Source
An infinite loop of behaviours and widgets over time, sampled forward.
busIteration :: MVar (Bus a) -> Behaviour a -> IO ()Source
Sample time and apply the behaviour to that sample.
produce :: String -> String -> String -> TimeSpan -> a -> IO (Diff a)Source
Assign an event to time given some event data and a TimeSpan.
produce group source nm timetolive edata
produce' :: String -> String -> String -> TimeSpan -> a -> MVar (Bus a) -> IO ()Source
Assign an event to time from a widget.
produce' group source nm timetolive edata bus
consumeNamedEventsCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future aSource
Sample all events with a given name at the current time and output their deletions as Diffs as well as any additional Diffs returned by the behaviour.
consumeNamedEvents :: String -> Behaviour aSource
consumeEventGroup :: String -> Behaviour aSource
modifyEventData :: Event a -> (a -> a) -> [Diff a]Source
consumeEventGroupCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future aSource
Sample all events with a given group at the current time and output their deletions as Diffs as well as any additional Diffs returned by the behaviour.
consumeEventsFromSourceCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future aSource
Sample all events with a given source at the current time and output their deletions as Diffs as well as any additional Diffs returned by the behaviour.
consumeFullyQualifiedEventWith :: Bus a -> String -> String -> String -> (Event a -> IO [Diff a]) -> Future aSource
Sample a single fully qualified event at the current time and output their deletions as Diffs as well as any additional Diffs returned by the behaviour. Parameter order is bus, group, source, name
pollNamedEventsCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future aSource
Sample all events with a given name and apply a Behaviour
pollNamedEventsWith :: Bus a -> String -> (Event a -> IO [Diff a]) -> Future aSource
Sample all events with a given name and apply a Behaviour to each
pollEventGroupCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future aSource
Sample all events with a given group and apply a Behaviour
pollEventGroupWith :: Bus a -> String -> (Event a -> IO [Diff a]) -> Future aSource
Sample all events with a gien group and apply a Behaviour to each.
pollEventsFromSourceCollectivelyWith :: Bus a -> String -> (Set (Event a) -> IO [Diff a]) -> Future aSource
Sample all events with a given source and apply a Behaviour
pollEventsFromSourceWith :: Bus a -> String -> (Event a -> IO [Diff a]) -> Future aSource
Sample all events with a given source and apply a Behaviour to each.
pollFullyQualifiedEventWith :: Bus a -> String -> String -> String -> (Event a -> IO [Diff a]) -> Future aSource
Sample a single fully qualified event and output some Diffs. Parameter order is bus, group, source, name.