Mercurial > hg > Members > toma > Jungle-haskell
diff test.hs @ 7:644e1345ee83
add debugging function
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 13 Jan 2014 11:43:41 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test.hs Mon Jan 13 11:43:41 2014 +0900 @@ -0,0 +1,36 @@ +{-# LANGUAGE OverloadedStrings #-} + +import Jungle +import Data.Maybe +import qualified Data.ByteString.Lazy.Char8 as B + +jungle = createJungle + +tree = do + a <- createTree jungle "test" + let + t = fromJust $ getTreeByName a "test" + node <- getRootNode t + return (add node) + +addc path pos node = addNewChildAt node path pos + +addchild = + (addc [3] 2) . (addc [] 3) . (addc [1,1] 2) . (addc [1,1] 1). (addc [2] 2) . (addc [1] 2) . + (addc [2] 1) . (addc [] 2). (addc [1] 1) . (addc [] 1) + +adda path key value node = putAttribute node path key value + +addattr = + (adda [1,1] "key" "value") . (adda [1,1] "test" "test2") . + (adda [] "root" "node") . (adda [1] "tes" "abc") . + (adda [3,2] "test" "3-2") . (adda [2,2] "test" "2-2") + +add = addattr . addchild + +{- +ghci> :l test.hs +ghci> y <- tree +ghci> putStrLn $ printAttributes y +ghci> putStrLn $ drawNode y +-}