module QTree where import ParseDecorate data Q s = QToken [s] | QBranch [Q s] deriving (Eq, Show) -- smart constructor branch :: [Q s] -> Q s branch [q] = q branch qs = QBranch qs -- Transforms a P-tree into a Q-tree. toQ :: P s -> Q s toQ = branch . toQs toQs :: P s -> [Q s] toQs = foldP ([], (:[]) . QToken, (:[]) . branch, \p q -> p ++ [branch q], undefined, undefined, undefined)