=== haskell ===
--data type Tree is
--either
-- a Leaf containing a single item (of type a)
-- or
-- a Node containing two subtrees (that can have leaves of type a)
data Tree a = Leaf a | Node (Tree a) (Tree a)
-- and it inherits 'methods' / 'roles' from types Show and Eq,
deriving (Show, Eq)
-- Fringe is a function that extracts a list of type a from a tree containing type a
fringe :: Tree a -> [a]
-- If its argument is of type leaf
-- it returns a single element list containing the element held in the leaf
fringe (Leaf x) = [x]
-- If its argument is a Node
-- it returns the list returned by the left subtree
-- concatenated to the list returned by the right subtree
fringe (Node n1 n2) = fringe n1 ++ fringe n2
-- sameFringe takes two Trees as its arguments
-- and uses the == method inherited/included from the Eq role
-- to compare the lists returned from the two trees for equality
-- returning true if they are the same.
sameFringe :: (Eq a) => Tree a -> Tree a -> Bool
sameFringe t1 t2 = fringe t1 == fringe t2