Mercurial > hg > Members > toma > Jungle-haskell
annotate test/test.hs @ 13:74a4c7cdc50b
fix test.hs
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 22 Jan 2014 14:22:43 +0900 |
parents | 29d0f605efa9 |
children | 824543aea6fc |
rev | line source |
---|---|
7 | 1 {-# LANGUAGE OverloadedStrings #-} |
2 | |
3 import Jungle | |
4 import Data.Maybe | |
5 import qualified Data.ByteString.Lazy.Char8 as B | |
6 | |
7 tree = do | |
13 | 8 jungle <- createTree createJungle "test" |
9 node <- getRootNode jungle "test" | |
7 | 10 return (add node) |
11 | |
12 addc path pos node = addNewChildAt node path pos | |
13 | |
14 addchild = | |
15 (addc [3] 2) . (addc [] 3) . (addc [1,1] 2) . (addc [1,1] 1). (addc [2] 2) . (addc [1] 2) . | |
16 (addc [2] 1) . (addc [] 2). (addc [1] 1) . (addc [] 1) | |
17 | |
18 adda path key value node = putAttribute node path key value | |
19 | |
20 addattr = | |
21 (adda [1,1] "key" "value") . (adda [1,1] "test" "test2") . | |
22 (adda [] "root" "node") . (adda [1] "tes" "abc") . | |
23 (adda [3,2] "test" "3-2") . (adda [2,2] "test" "2-2") | |
24 | |
10
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
25 add :: Node -> Node |
7 | 26 add = addattr . addchild |
27 | |
10
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
28 putNode = putStrLn . drawNode |
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
29 putAttr = putStrLn . printAttributes |
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
30 |
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
31 |
7 | 32 {- |
33 ghci> :l test.hs | |
34 ghci> y <- tree | |
35 ghci> putStrLn $ printAttributes y | |
36 ghci> putStrLn $ drawNode y | |
37 -} |