singleLineRegion :: Int -> String -> (Int, Int, Int, Int) -> Doc
singleLineRegion lineNum sourceLine (start, innerStart, innerEnd, end) =
  let
    width =
      length (show lineNum)

    underline =
      text (replicate (innerStart + width + 1) ' ')
      <>
      dullred (text (replicate (max 1 (innerEnd - innerStart)) '^'))

    trimmedSourceLine =
        sourceLine
          |> drop (start - 1)
          |> take (end - start + 1)
          |> (++) (replicate (start - 1) ' ')
  in
    addLineNumber Nothing width lineNum trimmedSourceLine
    <==>
    underline
singleLineRegion :: Int -> String -> (Int, Int, Int, Int) -> Doc
singleLineRegion lineNum sourceLine (start, innerStart, innerEnd, end) =
  let
    width =
      length (show lineNum)

    underline =
      text (replicate (innerStart + width + 1) ' ')
      <>
      dullred (text (replicate (max 1 (innerEnd - innerStart)) '^'))

    trimmedSourceLine =
        sourceLine
          |> drop (start - 1)
          |> take (end - start + 1)
          |> (++) (replicate (start - 1) ' ')
  in
    addLineNumber Nothing width lineNum trimmedSourceLine
    <==>
    underline
singleLineRegion lineNum sourceLine (start, innerStart, innerEnd, end) =
  let
    width =
      length (show lineNum)

    underline =
      text (replicate (innerStart + width + 1) ' ')
      <>
      dullred (text (replicate (max 1 (innerEnd - innerStart)) '^'))

    trimmedSourceLine =
        sourceLine
          |> drop (start - 1)
          |> take (end - start + 1)
          |> (++) (replicate (start - 1) ' ')
  in
    addLineNumber Nothing width lineNum trimmedSourceLine
    <==>
    underline