Dominic: move serialiser and deserialiser into record type class