Display example node

This commit is contained in:
Joscha 2020-02-08 23:33:25 +00:00
parent ff2dc3e783
commit 8fb3ab19c8
2 changed files with 14 additions and 4 deletions

View file

@ -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

View file

@ -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)
]