Missing space after tilde `~` [GHC-27207]

The ~ character can be used for multiple purposes:

If no space is placed between ~ and the expression that follows it, this is interpreted as the last bullet; in expression contexts, the lazy pattern is not allowed. The most likely case is that you wish to use ~ as a binary operator, in which case a space is needed following it.

Examples

Missing space after tilde `~`

There is no space after the tilde character ~.

Error Message

MissingSpaceLazyPattern.hs:11:9: error:
    Lazy pattern in expression context: ~1
    Did you mean to add a space after the '~'?
   |
11 | f x = x ~1
   |         ^^
MissingSpaceLazyPattern.hs
Before
module MissingSpaceLazyPattern where

(~) :: Int -> Int -> Bool
(~) a b = a == b

infixl 5 ~

f :: Int -> Bool
f x = x ~1
After
module MissingSpaceLazyPattern where

(~) :: Int -> Int -> Bool
(~) a b = a == b

infixl 5 ~

f :: Int -> Bool
f x = x ~ 1