import Test.QuickCheck
import Data.List

data NestedList a = Element a | List [NestedList a] deriving (Show)

myFlatten :: NestedList a -> [a]
myFlatten (Element a) = [a]
myFlatten (List []) = []
myFlatten (List x) = foldl1' (++) (map myFlatten x)

testMyFlatten :: [Int] -> Bool
testMyFlatten x =
	(length (myFlatten (List [])) == 0)
	&& (myFlatten (List (map Element x)) == x)
	&& (myFlatten
		(List [Element 1, List [Element 2,
			List [Element 3, Element 4], Element 5]])
		== [1,2,3,4,5])

main = quickCheck testMyFlatten
