view test/test.hs @ 19:824543aea6fc

delete Children and Attributes
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Fri, 24 Jan 2014 00:15:31 +0900
parents 74a4c7cdc50b
children 97d1e67aef15
line wrap: on
line source

{-# LANGUAGE OverloadedStrings #-}

import Jungle
import Data.Maybe
import qualified Data.ByteString.Lazy.Char8 as B

tree = do
    jungle <- createTree createJungle "test"
    node <- getRootNode jungle "test"
    return (add node)

addc path node = addNewChildAt node path

addchild = 
    (addc [3]) . (addc []) . (addc [1,1]) . (addc [1,1]). (addc [2]) . (addc [1]) . 
    (addc [2]) . (addc []). (addc [1]) . (addc [])

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,1] "test" "3-1") . (adda [2,2] "test" "2-2")

add :: Node -> Node
add = addattr . addchild

putNode = putStrLn . drawNode
putAttr = putStrLn . printAttributes 


{-
ghci> :l test.hs
ghci> y <- tree
ghci> putStrLn $ printAttributes y
ghci> putStrLn $ drawNode y
-}