Debian Codegraph @

tests/inputs/test2.lhs

raw
1
2 This is an extract of a larger literate Haskell file for testing
3 SLOCCount. It should have 21 lines of code.
4
5 This dumps the tree in dot format, which is very handy for visualizing
6 the trees.
7
8 > dotTree name t = "digraph " ++ filter dotChars name ++ " { " ++ (dotTree' t 0) ++ " }"
9
10 > dotTree' Empty _ = ""
11 > dotTree' t i | is_leaf t = "n"++(show i)++" [label=\""++(show $ x_span t)++
12 > "\",shape=box]; "
13 > | otherwise = "n"++(show i)++" [label=\""++(show $ x_span t)++"\"]; " ++
14 > "n"++(show i)++" -> n"++(show (2*i+1))++"; "++
15 > "n"++(show i)++" -> n"++(show (2*i+2))++"; "++
16 > dotTree' (left t) (2*i+1) ++
17 > dotTree' (right t) (2*i+2)
18 > where is_leaf Node { left = Empty, right = Empty } = True
19 > is_leaf _ = False
20 > {- this is a comment
21
22 foo bar baz
23
24 > that
25 > spans literate blocks -}
26
27 > dotChars '.' = False
28 > dotChars '/' = False
29 > dotChars _ = True
30
31 These functions fill in the monotonically increasing index values for
32 the lines in the finite map. They also do appropriate things to combine
33 the world values.
34
35 > idxList [] n = []
36 > idxList (x:xs) n = (x {idx=n}):(idxList xs (n+1))
37
38 > idxFM' fm (x,k) = addToFM (delFromFM fm k) k (y {idx=toInteger x})
39 > where y = case lookupFM fm k of
40 > Just foo -> foo
41 > Nothing -> error $ "No such key: " ++ show k
42
43 > idxFM fm = foldl idxFM' fm (zip [1..sizeFM fm] $ keysFM fm)
44