Tab character [GHC-94817]

Flag: -Wtabs
Enabled by default

Haskell’s syntax is indentation-sensitive, which means that a line’s indentation is syntactically meaningful. Two characters are allowed for indentation: spaces and tabs. However, tab characters are defined in the Haskell 2010 report to insert enough spaces to reach the next column whose number is a multiple of 8. This does not match the way that many editors and other environments render tab characters, so without great care, the use of tabs can lead to confusing syntax errors. In particular, GHC may end up interpreting two lines that visually appear to have the same amount of indentation as being indented differently, or two lines that visually appear to be indented differently as having the same indentation.

Examples

A file that uses a tab for indentation

Message

Tab.hs:5:1: warning: [-Wtabs] [GHC-94817]
    Tab character found here.
    Suggested fix: Please use spaces instead.
  |
5 |         x + y
  | ^^^^^^^^

Explanation

A tab character was found, which can be confusing. The warning can be addressed by replacing the tab with spaces.

Tab.hs
Before
module Tab where

add :: Int -> Int -> Int
add x y =
	x + y
After
module Tab where

add :: Int -> Int -> Int
add x y =
        x + y