1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 08:54:14 +03:00

Implement showJSON over Keyed nodes.

This commit is contained in:
Rob Rix 2016-02-29 17:41:29 -05:00
parent 5539d11d9a
commit 96649aa0e4

View File

@ -59,4 +59,4 @@ instance JSON recur => JSON (JSONWrapper (Syntax leaf recur)) where
showJSON (JSONWrapper (Leaf _)) = JSObject $ toJSObject [ ("type", JSString $ toJSString "leaf") ]
showJSON (JSONWrapper (Indexed i)) = JSObject $ toJSObject [ ("type", JSString $ toJSString "indexed"), ("children", showJSON i) ]
showJSON (JSONWrapper (Fixed i)) = JSObject $ toJSObject [ ("type", JSString $ toJSString "fixed"), ("children", showJSON i) ]
showJSON _ = JSNull
showJSON (JSONWrapper (Keyed k)) = JSObject $ toJSObject [ ("type", JSString $ toJSString "fixed"), ("children", JSObject $ toJSObject ((\ (k, v) -> (show k, showJSON v)) <$> (Map.toList k))) ]