further separation on f0 code
[fleet.git] / src / edu / berkeley / fleet / f0 / Util.lhs
1 \begin{code}
2 module Util where
3 import SBP
4
5 indent []       = []
6 indent ('\n':q) = "\n  "++(indent q)
7 indent (a:b)    = a:(indent b)
8
9 join c []    = ""
10 join c [x]   = x
11 join c (x:y) = x++c++(join c y)
12
13 class FromTree a where
14  fromTree  :: Tree   -> a
15 class FromTrees a where
16  fromTrees :: [Tree] -> a
17 instance FromTree a => FromTree [a] where
18  fromTree (Tree _ c _) = map fromTree c
19 instance FromTree  String where
20   fromTree  (Tree h c _) = h++(concatMap fromTree c)
21 instance FromTrees String where
22   fromTrees ts           = concatMap (fromTree :: Tree -> String) ts
23
24 \end{code}