diff --git a/src/Data/Range.hs b/src/Data/Range.hs index bc8d4c421..6aa222d5b 100644 --- a/src/Data/Range.hs +++ b/src/Data/Range.hs @@ -6,6 +6,8 @@ module Data.Range , intersectsRange ) where +import Data.Aeson +import Data.JSON.Fields import Data.Semigroup import Data.Text.Prettyprint.Doc import GHC.Generics @@ -37,3 +39,7 @@ instance Ord Range where instance Pretty Range where pretty (Range from to) = pretty from <> pretty '-' <> pretty to + + +instance ToJSONFields Range where + toJSONFields Range{..} = ["sourceRange" .= [ start, end ]] diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index 31edd0a6e..5b6bcaf52 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -56,9 +56,6 @@ instance (ToJSONFields a, ToJSONFields (f (Term f a))) => ToJSON (Term f a) wher toJSON = object . toJSONFields toEncoding = pairs . mconcat . toJSONFields -instance ToJSONFields Range where - toJSONFields Range{..} = ["sourceRange" .= [ start, end ]] - instance ToJSONFields Category where toJSONFields c = ["category" .= case c of { Other s -> s ; _ -> pack (show c) }]