addLineNumber :: Maybe R.Region -> Int -> Int -> String -> Doc
addLineNumber maybeSubRegion width n line =
  let
    number =
      if n < 0 then " " else show n

    lineNumber =
      replicate (width - length number) ' ' ++ number ++ "|"

    spacer (R.Region start end) =
      if R.line start <= n && n <= R.line end then
          dullred (text ">")
      else
          text " "
  in
    text lineNumber
    <> maybe (text " ") spacer maybeSubRegion
    <> text line
addLineNumber :: Maybe R.Region -> Int -> Int -> String -> Doc
addLineNumber maybeSubRegion width n line =
  let
    number =
      if n < 0 then " " else show n

    lineNumber =
      replicate (width - length number) ' ' ++ number ++ "|"

    spacer (R.Region start end) =
      if R.line start <= n && n <= R.line end then
          dullred (text ">")
      else
          text " "
  in
    text lineNumber
    <> maybe (text " ") spacer maybeSubRegion
    <> text line
addLineNumber maybeSubRegion width n line =
  let
    number =
      if n < 0 then " " else show n

    lineNumber =
      replicate (width - length number) ' ' ++ number ++ "|"

    spacer (R.Region start end) =
      if R.line start <= n && n <= R.line end then
          dullred (text ">")
      else
          text " "
  in
    text lineNumber
    <> maybe (text " ") spacer maybeSubRegion
    <> text line