• Iustin Pop's avatar
    Generalise the JSON "Container" type · edc1acde
    Iustin Pop authored
    
    
    Currently, we have some types that we kept as dictionaries in the
    objects representation (due to inconsistent behaviour, or other
    technical reasons). This should be improved in the future, but in the
    meantime we can improve the Container type by allowing its keys to be
    non-strings; this is needed, for example, for better safe in
    DiskParams type, where we don't want arbitrary strings as keys, but
    only the actually defined types.
    
    To implement this change, we generalise the type (Container →
    GenericContainer), and in the process we introduce a type class for
    "things that can be represented as strings". This is very similar to a
    combination of Read and Show, but with custom string
    representation. The new type class is needed because in JSON
    representation, object keys must be strings, so we need to be able to
    serialised/deserialise the generic keys to/from plain strings.
    
    We also add the instance for DiskTemplate at the same time.
    Signed-off-by: default avatarIustin Pop <iustin@google.com>
    Reviewed-by: default avatarAdeodato Simo <dato@google.com>
    edc1acde
Types.hs 7.28 KB