Consider Reader/Writer monad for reflex input and output
- Lingua principale
- Haskell
- Stelle
- 1.3k
- Fork
- 201
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Here's an interesting idea for `reflexOf`:
class (..., t ~ ...) => CodeWorldReflex t m where
keyPress :: m (Event t Text)
keyRelease :: m (Event t Text)
...
draw :: Dynamic t Picture -> m ()
reflexOf :: CodeWorldReflex m => m () -> IO ()
This would replace the existing `ReactiveInput` type, so it saves some complexity as well as adding it. `draw` replaces the `Dynamic t Picture` return value in the existing API.
This parallels the way reflex-dom works, where a builder monad can emit pieces of output on the screen. Under the scenes, there's just an implied top-level `pictures` function that combines all the emitted pictures into one screen.
Here's why this is appealing:
main = reflexOf $ do
param1 <- gauge $ gaugeConfig {
gaugeLabel = "param1",
gaugeRange = (1, 10),
gaugeStart = 5,
gaugePosition = (0, -6)
}
param2 <- gauge $ gaugeConfig {
gaugeLabel = "param2",
gaugeRange = (1, 10),
gaugeStart = 5,
gaugePosition = (0, -6)
}
param3 <- gauge $ gaugeConfig {
gaugeLabel = "param3",
gaugeRange = (1, 10),
gaugeStart = 5,
gaugePosition = (0, -6)
}
emit (renderWith <$> param1 <*> param2 <*> param3)
gauge GaugeConfig{..} = do
click <- pointerPress
release <- pointerRelease
dragging <- holdDyn $ mergeWith (&&) [
True <$ ffilter inBounds click,
False <$ release
]
drag <- gateDyn dragging =<< updated pointerPosition
value <- holdDyn gaugeStart (toValue <$> drag)
emit $ drawGauge <$> value
return value
where inBounds (x, y) = ...
toValue (x, y) = ...
drawGauge val = ...
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start by locating the existing ReactiveInput type and reflexOf API, then compare them with the proposed CodeWorldReflex interface and draw-based output model. The issue is complete only after the replacement API and its implications for input, output, and existing examples have been designed and agreed upon.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- haskell
- Ambito
- frontend
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100