From a504e73b04d4fd44267b791536c0f8ec8453c4e6 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 29 Feb 2016 17:15:08 -0500 Subject: [PATCH] Some more instances. --- src/Renderer/JSON.hs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index c3a07e53b..e16a21dc8 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -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