Skip to content

Changes to OverloadedLabels cause (#.) to fail to parse as identifier in GHC-9.6.1-alpha

Summary

It used to be the case that (#.) was a valid identifier both with and without the OverloadeLabels extension, but in GHC-9.6.1-alpha1 this is no longer the case when OverloadedLabels is enabled.

I noticed this because I tried to compile optics-core which both uses these literals and enabled the OverloadedLabels extensions (although I'm not sure if it needs to). For other uses see hoogle: https://hoogle.haskell.org/?hoogle=%23.

This is due to this GHC proposal https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst Implemented here: !8966 (closed)

I feel like we should at least do a better job documenting this change in behaviour.

Steps to reproduce

Compile this module

{-# LANGUAGE OverloadedLabels #-}
module Hash ((#.)) where

(#.) :: a
(#.) = undefined

Expected behavior

This module should compile or give a helpful error message. Instead it gives the following message:

Hash.hs:2:15: error: [GHC-58481] parse error on input ‘#.’
  |
2 | module Hash ((#.)) where

and if the export list is removed then:

Hash.hs:4:1: error: [GHC-94426]
    Invalid type signature: (#.) :: ...
    Suggested fix:
      A type signature should be of form <variables> :: <type>
  |
4 | (#.) :: a

Neither message makes it clear that these are no longer accepted as identifiers because they are now taken to be OverloadedLabels.

Environment

  • GHC version used: 9.6.1-alpha1
Edited by Teo Camarasu
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information