Smarter sorting and application of fix to handle multiple replacements

This commit is contained in:
Ng Zhi An 2018-11-02 22:13:49 -07:00
parent d5ba41035b
commit 3471ad45b1
3 changed files with 57 additions and 39 deletions

View file

@ -180,7 +180,7 @@ data Position = Position {
posFile :: String, -- Filename
posLine :: Integer, -- 1 based source line
posColumn :: Integer -- 1 based source column, where tabs are 8
} deriving (Show, Eq, Generic, NFData)
} deriving (Show, Eq, Generic, NFData, Ord)
newPosition :: Position
newPosition = Position {
@ -209,6 +209,9 @@ data Replacement = Replacement {
repString :: String
} deriving (Show, Eq, Generic, NFData)
instance Ord Replacement where
compare r1 r2 = (repStartPos r1) `compare` (repStartPos r2)
newReplacement = Replacement {
repStartPos = newPosition,
repEndPos = newPosition,