diff options
Diffstat (limited to 'compiler/basicTypes/SrcLoc.hs')
-rw-r--r-- | compiler/basicTypes/SrcLoc.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/basicTypes/SrcLoc.hs b/compiler/basicTypes/SrcLoc.hs index 7733aee3e1..e171e702be 100644 --- a/compiler/basicTypes/SrcLoc.hs +++ b/compiler/basicTypes/SrcLoc.hs @@ -45,6 +45,7 @@ module SrcLoc ( interactiveSrcSpan, srcLocSpan, realSrcLocSpan, combineSrcSpans, + srcSpanFirstCharacter, -- ** Deconstructing SrcSpan srcSpanStart, srcSpanEnd, @@ -342,6 +343,13 @@ combineRealSrcSpans span1 span2 (srcSpanEndLine span2, srcSpanEndCol span2) file = srcSpanFile span1 +-- | Convert a SrcSpan into one that represents only its first character +srcSpanFirstCharacter :: SrcSpan -> SrcSpan +srcSpanFirstCharacter l@(UnhelpfulSpan {}) = l +srcSpanFirstCharacter (RealSrcSpan span) = RealSrcSpan $ mkRealSrcSpan loc1 loc2 + where + loc1@(SrcLoc f l c) = realSrcSpanStart span + loc2 = SrcLoc f l (c+1) {- ************************************************************************ * * |