title: How to read a string representation of a binary tree back into the tree?
body: <p>I have the following code that accepts the input as the example given in <code>ex</code> and creates a tree with the give type:</p>
  <pre><code>data QA = Leaf String | Question QA String QA
  
  ex :: QA
  ex = (Question 
         (Question (Leaf &quot;Marie Curie&quot;) &quot;Is she a scientist?&quot; (Leaf &quot;Queen Elisabeth II&quot;))
         &quot;Is she from Europe?&quot;
         (Question (Leaf &quot;Marilyn Monroe&quot;) &quot;Is she an actress?&quot; (Leaf &quot;Hilary Clinton&quot;)))
  
  showQa :: QA -&gt; String 
  showQa (Leaf x) = &quot;(&quot; ++ x ++ &quot;)&quot;
  showQa (Question left x right) = &quot;(&quot; ++ x ++ showQa left ++ showQa right ++ &quot;)&quot;
  
  instance Show QA where
    show = showQa
  </code></pre>
  <p>Then I convert the tree to a string using the showQa function to be able to store it in a file with the following output as string:</p>
  <pre><code>&quot;(Is she from Europe?(Is she a scientist?(Marie Curie)(Queen Elisabeth II))(Is she an actress?(Marilyn Monroe)(Hilary Clinton)))&quot;
  </code></pre>
  <p>The problem is how can I convert this string to the original tree with the original type when I read the string from the file again.</p>