Opened 7 years ago

Closed 15 months ago

#1102 closed feature request (wontfix)

Lambda unicode character lex

Reported by: humasect Owned by:
Priority: normal Milestone:
Component: Compiler (Parser) Version: 6.6
Keywords: lambda unicode lexical parse ? Cc: pumpkingod@…, anton.nik@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Easy (less than 1 hour)
Test Case: Blocked By:
Blocking: Related Tickets:

Description

abd ∷ Num a ⇒ a → a
abd a = a

(⋴) a b = a ++ b
test2 x = map (λx → x ⋴ "abc") -- line 17

Test.hs:17:18: parse error on input `?'


All of these special characters are unicode, and work great, except the lambda. Any unicode character put here gives this error. http://hackage.haskell.org/trac/haskell-prime/wiki/UnicodeInHaskellSource -- claims otherwise.

Change History (13)

comment:1 follow-up: Changed 7 years ago by simonmar

  • Priority changed from high to normal
  • Resolution set to wontfix
  • Status changed from new to closed

I removed the claim on the Haskell-prime wiki, and also removed the failed attempt to support unicode lambda from GHC.

Further discussion is needed here: since λ is a lower-case letter, λx is an identifier. If we want to treat this as meaning \x, that means λ would need to be treated as a "special" character (like parentheses for example). No other alphanumeric character has this property, currently.

comment:2 Changed 7 years ago by humasect

  • Operating System changed from MacOS X to Multiple

This sounds like a simple enough strategy, to make it a special case. With or without an option to turn it on/off.
There is another similar character, ⋋, which is "left semidirect product" of mathematical symbols. Or ⋀ for "n-ary logical and". Sorry I don't have the unicode ID. So the error message from GHC is real and would have made sense if it were seen under a Unicode terminal. I wonder, some way to use lower case lambda letter as an identifier, aliased to actual lambda syntax? Thanks!

comment:3 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:4 Changed 6 years ago by simonmar

  • Operating System changed from Multiple to Unknown/Multiple

comment:5 in reply to: ↑ 1 Changed 5 years ago by pumpkin

  • Resolution wontfix deleted
  • severity changed from major to minor
  • Status changed from closed to reopened

Replying to simonmar:

I removed the claim on the Haskell-prime wiki, and also removed the failed attempt to support unicode lambda from GHC.

Further discussion is needed here: since λ is a lower-case letter, λx is an identifier. If we want to treat this as meaning \x, that means λ would need to be treated as a "special" character (like parentheses for example). No other alphanumeric character has this property, currently.

I'm reasonably sure this could be done unambiguously for the regular greek lambda, but it would add some complexity to the parse. As a simple alternative, we could use some of the new unicode characters from the "Math Alphanumeric Symbols" table (non-BMP). The following characters seem like valid candidates for really easy lexing (unfortunately almost no fonts actually provide glyphs for them, but in principle at least, it should be correct:

𝛌 (1D6CC, MATHEMATICAL BOLD SMALL LAMBDA)
𝜆 (1D706, MATHEMATICAL ITALIC SMALL LAMBDA)
𝝀 (1D740, MATHEMATICAL BOLD ITALIC SMALL LAMBDA)
𝝺 (1D77A, MATHEMATICAL SANS-SERIF BOLD SMALL LAMBDA)
𝞴 (1D7B0, MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL LAMBDA)

What do people think? Would making all these characters lex to behave like a \ be correct behavior? It would still be nice to get the regular BMP greek lambda to have special behavior when to the left of a -> (or equivalent unicode character) but that's a little context-sensitive.

comment:6 Changed 5 years ago by pumpkin

  • Cc pumpkingod@… added

comment:7 Changed 5 years ago by bos

Trouble is, all of those other lambdas have the Alphabetic property, just like the regular lambda. I have mathematical code that uses identifiers like µ and σ, so λ isn't that much of a stretch.

comment:8 Changed 4 years ago by simonmar

  • Difficulty changed from Easy (1 hr) to Easy (less than 1 hour)

comment:9 Changed 4 years ago by porges

  • Type changed from bug to feature request
  • Type of failure set to None/Unknown

I've been thinking that maybe even another arrow might work here, so that we have something like:

    map (x ↦ f x) ys

comment:10 Changed 4 years ago by simonmar

  • Milestone changed from 6.6.1 to _|_

comment:11 Changed 3 years ago by lelf

  • Cc anton.nik@… added

comment:12 Changed 15 months ago by morabbin

Seems like we're still at an impasses on this one: bos's comment above is hard to get around.

comment:13 Changed 15 months ago by igloo

  • Resolution set to wontfix
  • Status changed from new to closed

I think we've decided to leave lambda as a letter, and any alternative syntax would be better proposed on one of the mailing lists.

Note: See TracTickets for help on using tickets.