From 8fb3ab19c844fdec1f177b225d75c2308ff6d1cf Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 8 Feb 2020 23:33:25 +0000 Subject: [PATCH] Display example node --- client/Main.hs | 8 ++++---- src/Forest/Node.hs | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/client/Main.hs b/client/Main.hs index 9f8a408..98a4a03 100644 --- a/client/Main.hs +++ b/client/Main.hs @@ -42,9 +42,9 @@ data ClientState = ClientState , csEditor :: Maybe NodeEditor } -newClientState :: ClientState -newClientState = ClientState - { csTree = newTree $ emptyNode "Connecting..." False False False False +newClientState :: Node -> ClientState +newClientState node = ClientState + { csTree = newTree node , csEditor = Nothing } @@ -65,4 +65,4 @@ clientApp = App } main :: IO () -main = void $ defaultMain clientApp newClientState +main = void $ defaultMain clientApp $ newClientState exampleNode diff --git a/src/Forest/Node.hs b/src/Forest/Node.hs index b704be0..3dba86f 100644 --- a/src/Forest/Node.hs +++ b/src/Forest/Node.hs @@ -18,6 +18,8 @@ module Forest.Node , isValidPath , narrowPath , narrowSet + -- * Example values + , exampleNode ) where import Control.Monad @@ -86,3 +88,11 @@ narrowPath _ _ = Nothing narrowSet :: NodeId -> Set.Set Path -> Set.Set Path narrowSet x s = Set.fromList [Path ys | Path (y:ys) <- Set.toList s, x == y] + +{- For testing -} + +exampleNode :: Node +exampleNode = Node "Tool box" False False True False $ Map.fromList + [ ("hammer", Node "Hammer" False True False True Map.empty) + , ("nail", Node "Nail" False True False False Map.empty) + ]