mirror of
https://github.com/github/semantic.git
synced 2025-01-01 19:55:34 +03:00
Ranges and Spans have lower bounds.
This commit is contained in:
parent
2885698962
commit
890e6df098
@ -7,9 +7,10 @@ module Data.Range
|
||||
, subtractRange
|
||||
) where
|
||||
|
||||
import Prologue
|
||||
import Data.Aeson
|
||||
import Data.JSON.Fields
|
||||
import Data.Semilattice.Lower
|
||||
import Prologue
|
||||
|
||||
-- | A half-open interval of integers, defined by start & end indices.
|
||||
data Range = Range { start :: {-# UNPACK #-} !Int, end :: {-# UNPACK #-} !Int }
|
||||
@ -51,3 +52,6 @@ instance Ord Range where
|
||||
|
||||
instance ToJSONFields Range where
|
||||
toJSONFields Range{..} = ["sourceRange" .= [ start, end ]]
|
||||
|
||||
instance Lower Range where
|
||||
lowerBound = Range 0 0
|
||||
|
@ -9,10 +9,11 @@ module Data.Span
|
||||
, emptySpan
|
||||
) where
|
||||
|
||||
import Prologue
|
||||
import Data.Aeson ((.=), (.:))
|
||||
import qualified Data.Aeson as A
|
||||
import Data.JSON.Fields
|
||||
import Data.Semilattice.Lower
|
||||
import Prologue
|
||||
|
||||
-- | Source position information
|
||||
data Pos = Pos
|
||||
@ -56,3 +57,6 @@ instance A.FromJSON Span where
|
||||
|
||||
instance ToJSONFields Span where
|
||||
toJSONFields sourceSpan = [ "sourceSpan" .= sourceSpan ]
|
||||
|
||||
instance Lower Span where
|
||||
lowerBound = Span (Pos 1 1) (Pos 1 1)
|
||||
|
Loading…
Reference in New Issue
Block a user