get grammarfiles from classloader resources rather than files
[wix.git] / src / FromTree.lhs
1 \begin{code}
2 module FromTree
3 where
4 import Edu.Berkeley.Sbp.Haskell.SBP
5
6 class FromTree a where
7  fromTree  :: Tree   -> a
8 class FromTrees a where
9  fromTrees :: [Tree] -> a
10 instance FromTree a => FromTree [a] where
11  fromTree (Tree _ c _) = map fromTree c
12 instance FromTree a => FromTrees [a] where
13  fromTrees c = map fromTree c
14
15 instance FromTree  String where
16   fromTree  (Tree h c _) = h++(concatMap fromTree c)
17 instance FromTrees String where
18   fromTrees ts           = concatMap (fromTree :: Tree -> String) ts
19
20 instance FromTree  Int where
21   fromTree  t = read $ fromTree t
22 instance FromTrees Int where
23   fromTrees t = read $ fromTrees t
24
25 \end{code}