Parsing data of varying structure in Haskell with Aeson

Need to parse data with varying structure? Once again we resort to our old friend for handling exclusive possibilities, the sum type.

So, we’re getting an array of objects who can be either User, Employee, or a Manager. I’ve included the FromJSON instances for parsing JSON data into these individual objects. Now we get to where we handle the non-determinism of, “which type is it?”

And the final result when we run main?

Winrar.

I know this site is a bit of a disaster zone, but if you like my writing or think you could learn something useful from me, please take a look at the Haskell book I've been writing. There's a free sample available too!