Skip to content

Incorrect(?) suggestion with ticket constructors and `-Woperator-whitespace`

Summary

With -Weverything, the -Woperator-whitespace lint suggests changing a ticked constructor from foo ':<>: bar to foo ' :<>: bar.

Steps to reproduce

With OperatorWhitespace.hs:

{-# LANGUAGE DataKinds #-}

module OperatorWhitespace () where

import GHC.TypeLits (TypeError, ErrorMessage(Text, (:<>:)))

type MyError :: forall k. k
type MyError = TypeError ('Text "Error" ':<>: 'Text "Error")

Compiling the file gives this warning (maybe a mis-parse?)

$ ghc -Weverything OperatorWhitespace.hs
OperatorWhitespace.hs:8:42: warning: [GHC-40798] [-Woperator-whitespace]
    The suffix use of a ‘:<>:’ might be repurposed as special syntax
      by a future language extension.
    Suggested fix: Add whitespace around ‘:<>:’.
  |
8 | type MyError = TypeError ('Text "Error" ':<>: 'Text "Error")
  |                                          ^^^^

The lint goes away when I change it to type MyError = TypeError ('Text "Error" ' :<>: 'Text "Error").

Expected behavior

Adding whitespace between the operator and the promotion tick looks really weird. Surely this isn't the intended syntax?

type MyError = TypeError ('Text "Error" ' :<>: 'Text "Error")

I would expect ':<>: to parse correctly without warnings.

Environment

  • GHC version used: 9.6.1
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.6.1

Optional:

  • Operating System: macOS
  • System Architecture: aarch64
$ uname -a
Darwin san-fransisco 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64
Edited by Rebecca Turner
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information