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:
parent
5802d4678d
commit
10e4bbb5a6
@ -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 }
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user