From 0845687d51cb52f29c3c1139c9d3aab708bf4f55 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Sat, 9 Sep 2017 17:25:55 +0100 Subject: [PATCH] Move the ToJSONFields instance for Syntax into Syntax. --- src/Renderer/JSON.hs | 4 ---- src/Syntax.hs | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index 6f1f428ee..989c4c7b8 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -23,7 +23,6 @@ import Diff import GHC.Generics import Info import Language -import Syntax as S import Term -- @@ -69,9 +68,6 @@ instance (ToJSONFields a, ToJSONFields (f b), ToJSONFields (f (Term f a))) => To toJSONFields (Copy a f) = toJSONFields a <> toJSONFields f toJSONFields (Patch a) = toJSONFields a -instance ToJSON recur => ToJSONFields (Syntax recur) where - toJSONFields syntax = [ "children" .= toList syntax ] - data File a = File { filePath :: FilePath, fileLanguage :: Maybe Language, fileContent :: a } deriving (Generic, Show) diff --git a/src/Syntax.hs b/src/Syntax.hs index f501d71f4..d71c088bb 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -3,10 +3,12 @@ module Syntax where import Data.Aeson import Data.Align.Generic +import Data.Foldable (toList) import Data.Functor.Classes import Data.Functor.Classes.Eq.Generic import Data.Functor.Classes.Pretty.Generic import Data.Functor.Classes.Show.Generic +import Data.JSON.Fields import Data.Mergeable import Data.Text (Text) import GHC.Generics @@ -123,3 +125,6 @@ extractLeafValue syntax = case syntax of instance Eq1 Syntax where liftEq = genericLiftEq instance Show1 Syntax where liftShowsPrec = genericLiftShowsPrec instance Pretty1 Syntax where liftPretty = genericLiftPretty + +instance ToJSON recur => ToJSONFields (Syntax recur) where + toJSONFields syntax = [ "children" .= toList syntax ]