- Make state immutable (in PS everything is immutable so 0 overhead for this)
- No
getters
, nomutations
: Lens, or something similar, may work hereget :: forall state a. (state -> a) -> ActionT state () a
commit :: forall state. (state -> state) -> ActionT state () Unit
actions :: forall state eff. ActionT state (Aff eff) Unit
?
data AppState = AppState { counter :: Int }
type Action eff = ActionT AppState (Aff eff) Unit
-- guess we already have lenses for AppState
reqIncreaseCounter :: Action (http :: HTTP)
reqIncreaseCounter = do
c <- get (_AppState..counter)
increased <- someRequest c
increaseCounter increased
increaseCounter :: Int -> Action ()
increaseCounter increased = do
commit (_AppState..counter +~ increased)
Thinking about how to express computed properties.