\begin{code}
-- Copyright 2008 the Contributors, as shown in the revision logs.
-- Licensed under the Apache Public Source License 2.0 ("the License").
-- You may not use this file except in compliance with the License.

module FromTree
where
import Edu_Berkeley_Sbp_Haskell_SBP

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 a => FromTrees [a] where
 fromTrees 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

instance FromTree  Int where
  fromTree  t = read $ fromTree t
instance FromTrees Int where
  fromTrees t = read $ fromTrees t

\end{code}
