Revision 84835174
ID | 84835174c3e5f34be9849d4b329b20ba84d3e780 |
Parent | d8cb8e13 |
Child | d5a93a80 |
Improve the TH 'Container' type
This is the first part of the changes related to the 'Container' type.
We currently handle this type as follows: it's a simple type alias
over the Data.Map type, which means:
- it's easy to use the Data.Map functions to change the type
- however, since Data.Map already has a JSON instance, we have to very
carefully always use custom show/read routines to handle this type
The second point leads to potential bugs which are not caught by the
type system, so let's improve the situation by making it a proper
newtype, which can have its own JSON instance (with our desired
behaviour). Once we do this change, accessing the type requires an
extra function call, but it's as safe as before. On the positive side,
we can use the implicit read/show JSON, which means we can remove (in
the next patch) the "container" special casing.
The patch also moves the type to outside of THH, since not all users
of this will want to import that (as opposed to JSON.hs, which is
smaller).
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>
Files
- added
- modified
- copied
- renamed
- deleted