<p dir="ltr">You can create a readLayer function that returns something like this:</p>
<p dir="ltr">   <i> data</i><i> OneLayer</i><i> =</i><i> forall</i><i> a. Layer a =></i><i> OneLayer</i><i> a</i></p>
<p dir="ltr">Such that we get:</p>
<p dir="ltr"><i>    -- Read next layer</i><br>
<i>   </i><i> </i><i>readLayer</i><i> :: Handle -> IO</i><i> </i><i>OneLayer</i></p>
<p dir="ltr">Still, I feel that an ADT that combines all types is better as it fits the problem perfectly. Every time you add a new layer it will generate warnings for missing pattern matches.</p>
<p dir="ltr">Regards,<br>
  Sumit</p>