-- A very simple parser monad.
newtype Parser t a = Parser { runparse :: [t] -> Either String (a, [t]) }
-- A very simple parser monad.
newtype Parser t a = Parser { runparse :: [t] -> Either String (a, [t]) }
_ -> fail "trailing junk"
-----------------------------------------------------------------------------
_ -> fail "trailing junk"
-----------------------------------------------------------------------------
-- Return the elements inorder, as a list.
fringe t = gather t [] where
gather Leaf ns = ns
-- Return the elements inorder, as a list.
fringe t = gather t [] where
gather Leaf ns = ns
-- Answer whether two trees have the same fringe.
sameFringe t tt = fringe t == fringe tt -- trivial!
-- Answer whether two trees have the same fringe.
sameFringe t tt = fringe t == fringe tt -- trivial!