Change opcode/luxi showJSON generation in THH
authorIustin Pop <iustin@google.com>
Tue, 4 Dec 2012 09:55:02 +0000 (10:55 +0100)
committerIustin Pop <iustin@google.com>
Tue, 4 Dec 2012 11:44:44 +0000 (12:44 +0100)
commit84c2e6ca8c70402f25df9bc498a33f32f9c7fc23
tree44440e74f5bc723e6e0ee0215491e4385dc95068
parente45be9d47bcc3a8b31a13ba0bee525f872db27a1
Change opcode/luxi showJSON generation in THH

Currently, the opcode and luxi "showJSON" functions generate directly
a JSValue; in contrast, the object (single-constructor) types generate
a 'toDict' function, and then `showJSON = makeObj . toDict`. This is
useful, as the 'dict' form can be manipulated if needed.

This patch changes the opcode and luxi types to behave the same; we
generate a dict, and then (since this differs between opcodes and
luxi) generate showJSON either as `makeObj . toDict` (for opcodes), or
(for luxi) `showJSON . map sn . toDict`.

The change is needed for MetaOpCode implementation.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
htools/Ganeti/THH.hs