From aa074d181bfda7642bf18a57d768b05382c09843 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 15 Mar 2020 22:29:45 +0000 Subject: [PATCH] [server] Rename "graft" to "draw" --- forest-cabin/app/Main.hs | 9 ++++----- forest-server/src/Forest/Server/TreeApp.hs | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/forest-cabin/app/Main.hs b/forest-cabin/app/Main.hs index 1d75ba1..b8443cd 100644 --- a/forest-cabin/app/Main.hs +++ b/forest-cabin/app/Main.hs @@ -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 } diff --git a/forest-server/src/Forest/Server/TreeApp.hs b/forest-server/src/Forest/Server/TreeApp.hs index a33dd01..a43e16d 100644 --- a/forest-server/src/Forest/Server/TreeApp.hs +++ b/forest-server/src/Forest/Server/TreeApp.hs @@ -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