1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 00:44:57 +03:00

Some more instances.

This commit is contained in:
Rob Rix 2016-02-29 17:15:08 -05:00
parent 25214616c8
commit a504e73b04

View File

@ -4,6 +4,7 @@ module Renderer.JSON (
) where
import Alignment
import Category
import Control.Arrow
import Control.Monad.Free
import Data.Foldable
@ -32,5 +33,16 @@ instance JSON a => JSON (JSONWrapper (Line a)) where
showJSON (JSONWrapper EmptyLine) = JSNull
showJSON (JSONWrapper (Line a)) = showJSONs (toList a)
instance JSON Range where
showJSON (Range start end) = showJSON [ start, end ]
instance JSON (JSONWrapper Range) where
showJSON (JSONWrapper (Range start end)) = showJSON [ start, end ]
instance JSON (JSONWrapper Info) where
showJSON (JSONWrapper (Info range categories)) = JSObject $ toJSObject [("range", showJSON (JSONWrapper range)), ("categories", showJSON (showCategory <$> toList categories))]
where showCategory (Other s) = s
showCategory s = show s
instance JSON (JSONWrapper (SplitDiff a Info)) where
showJSON _ = JSNull
instance JSON a => JSON (JSONWrapper (SplitPatch a)) where
showJSON _ = JSNull