Commit 864388a3 authored by simonpj's avatar simonpj
Browse files

[project @ 2004-10-04 09:27:32 by simonpj]

Make combineSrcSpans commutative
parent a022fe50
...@@ -284,19 +284,23 @@ mkSrcSpan loc1 loc2 ...@@ -284,19 +284,23 @@ mkSrcSpan loc1 loc2
file = srcLocFile loc1 file = srcLocFile loc1
combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan
-- Assumes the 'file' part is the same in both
combineSrcSpans (ImportedSpan str) _ = ImportedSpan str combineSrcSpans (ImportedSpan str) _ = ImportedSpan str
combineSrcSpans (UnhelpfulSpan str) r = r -- this seems more useful combineSrcSpans (UnhelpfulSpan str) r = r -- this seems more useful
combineSrcSpans _ (ImportedSpan str) = ImportedSpan str combineSrcSpans _ (ImportedSpan str) = ImportedSpan str
combineSrcSpans l (UnhelpfulSpan str) = l combineSrcSpans l (UnhelpfulSpan str) = l
combineSrcSpans start end combineSrcSpans start end
| line1 == line2 = if col1 == col2 = case line1 `compare` line2 of
then SrcSpanPoint file line1 col1 EQ -> case col1 `compare` col2 of
else SrcSpanOneLine file line1 col1 col2 EQ -> SrcSpanPoint file line1 col1
| otherwise = SrcSpanMultiLine file line1 col1 line2 col2 LT -> SrcSpanOneLine file line1 col1 col2
GT -> SrcSpanOneLine file line1 col2 col1
LT -> SrcSpanMultiLine file line1 col1 line2 col2
GT -> SrcSpanMultiLine file line2 col2 line1 col1
where where
line1 = srcSpanStartLine start line1 = srcSpanStartLine start
line2 = srcSpanEndLine end
col1 = srcSpanStartCol start col1 = srcSpanStartCol start
line2 = srcSpanEndLine end
col2 = srcSpanEndCol end col2 = srcSpanEndCol end
file = srcSpanFile start file = srcSpanFile start
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment