1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

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

This commit is contained in:
Rob Rix 2019-09-20 12:18:56 -04:00
parent 5802d4678d
commit 10e4bbb5a6
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
2 changed files with 4 additions and 5 deletions

View File

@ -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 }

View File

@ -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