Yeah, I'm starting to think the ADT makes the most sense. With the readLayer call though, how do you know which layer to read? Or are you still stuck with the failing to parse a list of potentials and then taking the one that doesnt fail?

Thanks,


Charlie

On Mon, Apr 18, 2016 at 7:45 PM, Sumit Sahrawat, Maths & Computing, IIT (BHU) <sumit.sahrawat.apm13@iitbhu.ac.in> wrote:

You can create a readLayer function that returns something like this:

    data OneLayer = forall a. Layer a => OneLayer a

Such that we get:

    -- Read next layer
    readLayer :: Handle -> IO OneLayer

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.

Regards,
  Sumit