1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Move the ToJSONFields instance for Location into Data.JSON.Fields.

This commit is contained in:
Rob Rix 2019-09-20 14:08:41 -04:00
parent ddef7139f6
commit 81f43c9881
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
2 changed files with 4 additions and 6 deletions

View File

@ -10,8 +10,7 @@ module Data.JSON.Fields
import Data.Aeson
import qualified Data.Map as Map
import Data.Range
import Data.Span
import Data.Location
import Data.Sum (Apply (..), Sum)
import qualified Data.Text as Text
import GHC.Generics
@ -54,6 +53,9 @@ instance ToJSONFields Range where
instance ToJSONFields Span where
toJSONFields sourceSpan = [ "sourceSpan" .= sourceSpan ]
instance ToJSONFields Location where
toJSONFields Location{..} = toJSONFields locationByteRange <> toJSONFields locationSpan
newtype JSONFields a = JSONFields { unJSONFields :: a }

View File

@ -9,7 +9,6 @@ module Data.Location
import Prologue
import Control.Lens.Lens
import Data.JSON.Fields
import Data.Range
import Data.Span
@ -24,6 +23,3 @@ data Location
instance HasSpan Location where
span = lens locationSpan (\l s -> l { locationSpan = s })
{-# INLINE span #-}
instance ToJSONFields Location where
toJSONFields Location{..} = toJSONFields locationByteRange <> toJSONFields locationSpan