1
1
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:
Rob Rix 2018-04-30 17:07:01 -04:00
parent 2885698962
commit 890e6df098
2 changed files with 10 additions and 2 deletions

View File

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

View File

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