@@ -58,21 +58,14 @@ grabRegion maybeSubRegion (R.Region start end) source =
59 error "something has gone badly wrong with reporting source locations"
59 error "something has gone badly wrong with reporting source locations"
61− [theLine] ->
61+ [sourceLine] ->
63− n = startLine
62+ singleLineRegion startLine sourceLine $
64− w = length (show (n + 1))
63+ case maybeSubRegion of
66− replicate (startColumn - 1) ' '
67− ++ replicate (max 1 (endColumn - startColumn)) '^'
69− addLineNumber Nothing w
64+ Nothing ->
70− in
65+ (0, startColumn, endColumn, length sourceLine)
72− [ number (n-1) ""
67+ Just (R.Region s e) ->
73− , number n theLine
68+ (startColumn, R.column s, R.column e, endColumn)
74− , number (n+1) underline
77 firstLine : rest ->
70 firstLine : rest ->
@@ -112,3 +105,28 @@ addLineNumber maybeSubRegion width n line =
112 replicate (width - length number) ' ' ++ number
105 replicate (width - length number) ' ' ++ number
113 ++ "|" ++ maybe " " spacer maybeSubRegion
106 ++ "|" ++ maybe " " spacer maybeSubRegion
110+singleLineRegion :: Int -> String -> (Int, Int, Int, Int) -> String
111+singleLineRegion lineNum sourceLine (start, innerStart, innerEnd, end) =
113+ w = length (show (lineNum + 1))
116+ addLineNumber Nothing w
119+ replicate (innerStart - 1) ' '
120+ ++ replicate (max 1 (innerEnd - innerStart)) '^'
125+ |> take (end - start + 1)
126+ |> (++) (replicate (start - 1) ' ')
129+ [ number (lineNum-1) ""
130+ , number lineNum trimmedSourceLine
131+ , number (lineNum+1) underline