further separation on f0 code
[fleet.git] / src / edu / berkeley / fleet / f0 / Util.lhs
index e2cb5de..6f27ee9 100644 (file)
@@ -1,5 +1,6 @@
 \begin{code}
 module Util where
+import SBP
 
 indent []       = []
 indent ('\n':q) = "\n  "++(indent q)
@@ -8,4 +9,16 @@ indent (a:b)    = a:(indent b)
 join c []    = ""
 join c [x]   = x
 join c (x:y) = x++c++(join c y)
+
+class FromTree a where
+ fromTree  :: Tree   -> a
+class FromTrees a where
+ fromTrees :: [Tree] -> a
+instance FromTree a => FromTree [a] where
+ fromTree (Tree _ c _) = map fromTree c
+instance FromTree  String where
+  fromTree  (Tree h c _) = h++(concatMap fromTree c)
+instance FromTrees String where
+  fromTrees ts           = concatMap (fromTree :: Tree -> String) ts
+
 \end{code}
\ No newline at end of file