import Data.List (intercalate) data Node = List [Node] | Num Int deriving (Eq) -- here's a Show instance for Node that recreates the input: instance Show Node where show (List x) = "[" ++ intercalate "," (map show x) ++ "]" show (Num n) = show n