From 10e4bbb5a62751ab4b8813f169b01374ac9f4dc7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 20 Sep 2019 12:18:56 -0400 Subject: [PATCH] Move the ToJSONFields instance for Span into Data.JSON.Fields. --- src/Data/JSON/Fields.hs | 4 ++++ src/Data/Span.hs | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Data/JSON/Fields.hs b/src/Data/JSON/Fields.hs index b5344031c..7d8f0670c 100644 --- a/src/Data/JSON/Fields.hs +++ b/src/Data/JSON/Fields.hs @@ -11,6 +11,7 @@ module Data.JSON.Fields import Data.Aeson import qualified Data.Map as Map import Data.Range +import Data.Span import Data.Sum (Apply (..), Sum) import qualified Data.Text as Text import GHC.Generics @@ -50,6 +51,9 @@ instance (ToJSONFields a, ToJSONFields b) => ToJSONFields (a, b) where instance ToJSONFields Range where toJSONFields Range{..} = ["sourceRange" .= [ start, end ]] +instance ToJSONFields Span where + toJSONFields sourceSpan = [ "sourceSpan" .= sourceSpan ] + newtype JSONFields a = JSONFields { unJSONFields :: a } diff --git a/src/Data/Span.hs b/src/Data/Span.hs index 65a6e3fea..9007f4fbd 100644 --- a/src/Data/Span.hs +++ b/src/Data/Span.hs @@ -21,8 +21,6 @@ import Data.Aeson ((.:), (.=)) import qualified Data.Aeson as A import Proto3.Suite -import Data.JSON.Fields - -- | Source position information (1 indexed) data Pos = Pos { posLine :: !Int @@ -102,8 +100,5 @@ instance A.FromJSON Span where o .: "start" <*> o .: "end" -instance ToJSONFields Span where - toJSONFields sourceSpan = [ "sourceSpan" .= sourceSpan ] - instance Lower Span where lowerBound = emptySpan