| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
FRP.Rhine.Gloss.Pure.Combined
Contents
Description
A pure gloss backend for Rhine,
with separated event and simulation loop.
To run pure Rhine apps with gloss,
write a signal network (SN) in the GlossCombinedClock and use flowGlossCombined.
As an easy starter, you can use the helper function buildGlossRhine.
Synopsis
- type GlossCombinedClock a = SequentialClock (GlossEventClock a) GlossSimulationClock
- type GlossEventClock a = SelectClock GlossClock a
- glossEventSelectClock :: (Event -> Maybe a) -> GlossEventClock a
- glossEventClock :: GlossEventClock Event
- type GlossSimulationClock = SelectClock GlossClock ()
- glossSimulationClock :: GlossSimulationClock
- type GlossRhine a = Rhine GlossM (GlossCombinedClock a) () ()
- buildGlossRhine :: (Event -> Maybe a) -> ClSF GlossM GlossSimulationClock [a] () -> GlossRhine a
Documentation
type GlossCombinedClock a = SequentialClock (GlossEventClock a) GlossSimulationClock Source #
The overall clock of a pure rhine SN that can be run by gloss.
It is combined of two subsystems, the event part and the simulation part.
a is the type of subevents that are selected.
Events
type GlossEventClock a = SelectClock GlossClock a Source #
The clock that ticks whenever a specific gloss event occurs.
glossEventSelectClock :: (Event -> Maybe a) -> GlossEventClock a Source #
Select the relevant events by converting them to Just a,
and the irrelevant ones to Nothing.
glossEventClock :: GlossEventClock Event Source #
Tick on every event.
Simulation
type GlossSimulationClock = SelectClock GlossClock () Source #
The clock that ticks for every gloss simulation step.
Signal networks
type GlossRhine a = Rhine GlossM (GlossCombinedClock a) () () Source #
The type of a valid Rhine that can be run by gloss,
if you chose to separate events and simulation into two subsystems.
a is the type of subevents that are selected.
All painting has to be done in GlossM, e.g. via the paint method.
Typically, such a Rhine is built something like this:
-- | Select only key press events
myEventClock :: GlossEventClock Key
myEventClock = glossEventSelectClock selector
where
selector (EventKey key _ _ _) = Just key
selector _ = Nothing
myEventSubsystem :: ClSF GlossM GlossEventClock () MyType
myEventSubsystem = ...
mySim :: ClSF GlossM GlossSimulationClock [MyType] ()
mySim = ...
myGlossRhine :: GlossRhine a
myGlossRhine
= myEventSubsystem @ myEventClock >-- collect --> mySim @ glossSimulationClock
Arguments
| :: (Event -> Maybe a) | The event selector |
| -> ClSF GlossM GlossSimulationClock [a] () | The |
| -> GlossRhine a |
For most applications, it is sufficient to implement a single signal function that is called with a list of all relevant events that occurred in the last tick.