[server] Rename "graft" to "draw"

This commit is contained in:
Joscha 2020-03-15 22:29:45 +00:00
parent 83406dff10
commit aa074d181b
2 changed files with 7 additions and 8 deletions

View file

@ -35,8 +35,8 @@ data AppState = AppState
, asSharedNode :: Node
}
graft :: AppState -> Node
graft = asSharedNode
draw :: AppState -> Node
draw = asSharedNode
updateSharedNode :: AppState -> (Node -> Node) -> IO AppState
updateSharedNode s f = do
@ -61,8 +61,7 @@ handleEvent s (Delete path) = do
handleEvent s (Reply path text) = do
s' <- updateSharedNode s $ appendAt (txtNode "edr" text) path
pure $ continue s'
handleEvent s _ = do
pure $ continue s
handleEvent s _ = pure $ continue s
constructor
:: TChan AppEvent
@ -81,7 +80,7 @@ main = do
sharedNodeVar <- newMVar $ txtNode "r" "Sandbox"
broadcastChan <- atomically newBroadcastTChan
let app = TreeApp
{ appGraft = graft
{ appDraw = draw
, appHandleEvent = handleEvent
, appConstructor = constructor broadcastChan sharedNodeVar
}

View file

@ -39,7 +39,7 @@ data Event e
| Custom e
data TreeApp s e = TreeApp
{ appGraft :: s -> Node
{ appDraw :: s -> Node
, appHandleEvent :: s -> Event e -> IO (Next s)
, appConstructor :: forall a. (s -> Maybe (TChan e) -> IO a) -> IO a
}
@ -93,7 +93,7 @@ runUntilHalt conn app rs = do
case next of
Halt -> pure ()
Continue state' -> do
let node' = appGraft app state'
let node' = appDraw app state'
sendNodeUpdate conn (rsNode rs) node'
runUntilHalt conn app rs{rsState = state', rsNode = node'}
@ -106,7 +106,7 @@ runTreeApp pingDelay app pendingConn = do
firstPacket <- receivePacket conn
case firstPacket of
ClientHello _ -> do
let initialNode = appGraft app initialState
let initialNode = appDraw app initialState
rs = RunState chan customChan initialState initialNode
sendPacket conn $ ServerHello [] initialNode
withThread (receiveThread conn chan) $ runUntilHalt conn app rs