Skip to content

Allow unicode sub/superscript symbols in operators

While #4373 (closed) permits

Prelude> let v₁ = 1

the following is rejected

Prelude> let m >>=₁ f = undefined

<interactive>:0:10: lexical error at character '\8321'

Identifiers with non-numeric subscripts are not accepted either:

Prelude> let vₐ = 1

<interactive>:0:6: lexical error at character '\8336'

I wrote a small patch that makes such definitions possible.

  1. A new unicode Alex macro, $subsup, is introduced and added to $idchar, $symchar, and $graphic
  2. A unicode code point is classified as $subsup by alexGetChar iff either of the following holds:

a. The code point is annotated with <sub> or <super> in http://www.unicode.org/Public/UNIDATA/UnicodeData.txt

b. It is the [DOUBLE/TRIPLE/QUADRUPLE] PRIME (U+2032, U+2033, U+2034, U+2057)

Trac metadata
Trac field Value
Version 7.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by Thomas Miedema
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information