-combineSrcSpans start end
- = case line1 `compare` line2 of
- EQ -> case col1 `compare` col2 of
- EQ -> SrcSpanPoint file line1 col1
- 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
+combineSrcSpans (RealSrcSpan span1) (RealSrcSpan span2)
+ = RealSrcSpan (combineRealSrcSpans span1 span2)
+
+-- | Combines two 'SrcSpan' into one that spans at least all the characters
+-- within both spans. Assumes the "file" part is the same in both inputs
+combineRealSrcSpans :: RealSrcSpan -> RealSrcSpan -> RealSrcSpan
+combineRealSrcSpans span1 span2
+ = if line_start == line_end
+ then if col_start == col_end
+ then SrcSpanPoint file line_start col_start
+ else SrcSpanOneLine file line_start col_start col_end
+ else SrcSpanMultiLine file line_start col_start line_end col_end