1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Construct Values from Terms using termFields.

This commit is contained in:
Rob Rix 2016-03-01 13:48:57 -05:00
parent 60e0ca3337
commit 526c9ba26f

View File

@ -56,7 +56,7 @@ instance (ToJSON recur) => ToJSON (Syntax leaf recur) where
toJSON (Fixed c) = object [ "type" .= String "fixed", "children" .= Array (fromList $ toJSON <$> c) ]
toJSON (Keyed c) = object [ "type" .= String "fixed", "children" .= object (uncurry (.=) <$> toList c) ]
instance ToJSON (Term leaf Info) where
toJSON (Info range categories :< syntax) = object [ "range" .= toJSON range, "categories" .= toJSON categories, "syntax" .= toJSON syntax ]
toJSON (info :< syntax) = object (termFields info syntax)
toEncoding (info :< syntax) = pairs (termSeries info syntax)
termSeries :: ToJSON recur => Info -> Syntax leaf recur -> Series