GHC: Ticket #1102: Lambda unicode character lex
http://ghc.haskell.org/trac/ghc/ticket/1102
<p>
abd ∷ Num a ⇒ a → a
abd a = a
</p>
<p>
(⋴) a b = a ++ b
test2 x = map (λx → x ⋴ "abc") -- line 17
</p>
<p>
Test.hs:17:18: parse error on input `?'
</p>
<hr />
<p>
All of these special characters are unicode, and work great, except the lambda. Any unicode character put here gives this error. <a class="ext-link" href="http://hackage.haskell.org/trac/haskell-prime/wiki/UnicodeInHaskellSource"><span class="icon"></span>http://hackage.haskell.org/trac/haskell-prime/wiki/UnicodeInHaskellSource</a> -- claims otherwise.
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/1102
Trac 1.0.1simonmarTue, 16 Jan 2007 16:16:24 GMTpriority, status changed; resolution set
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:1
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:1
<ul>
<li><strong>priority</strong>
changed from <em>high</em> to <em>normal</em>
</li>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>wontfix</em>
</li>
</ul>
<p>
I removed the claim on the Haskell-prime wiki, and also removed the failed attempt to support unicode lambda from GHC.
</p>
<p>
Further discussion is needed here: since λ is a lower-case letter, λx is an identifier. If we want to treat this as meaning <tt>\x</tt>, that means λ would need to be treated as a "special" character (like parentheses for example). No other alphanumeric character has this property, currently.
</p>
TickethumasectWed, 17 Jan 2007 07:40:45 GMTos changed
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:2
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:2
<ul>
<li><strong>os</strong>
changed from <em>MacOS X</em> to <em>Multiple</em>
</li>
</ul>
<p>
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!
</p>
TicketsimonmarTue, 30 Sep 2008 15:40:06 GMTarchitecture changed
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:3
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:3
<ul>
<li><strong>architecture</strong>
changed from <em>Unknown</em> to <em>Unknown/Multiple</em>
</li>
</ul>
TicketsimonmarTue, 30 Sep 2008 15:54:46 GMTos changed
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:4
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:4
<ul>
<li><strong>os</strong>
changed from <em>Multiple</em> to <em>Unknown/Multiple</em>
</li>
</ul>
TicketpumpkinTue, 15 Sep 2009 20:50:23 GMTstatus, severity changed; resolution deleted
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:5
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:5
<ul>
<li><strong>status</strong>
changed from <em>closed</em> to <em>reopened</em>
</li>
<li><strong>resolution</strong>
<em>wontfix</em> deleted
</li>
<li><strong>severity</strong>
changed from <em>major</em> to <em>minor</em>
</li>
</ul>
<p>
Replying to <a class="closed" href="http://ghc.haskell.org/trac/ghc/ticket/1102#comment:1" title="Comment 1 for Ticket #1102">simonmar</a>:
</p>
<blockquote class="citation">
<p>
I removed the claim on the Haskell-prime wiki, and also removed the failed attempt to support unicode lambda from GHC.
</p>
<p>
Further discussion is needed here: since λ is a lower-case letter, λx is an identifier. If we want to treat this as meaning <tt>\x</tt>, that means λ would need to be treated as a "special" character (like parentheses for example). No other alphanumeric character has this property, currently.
</p>
</blockquote>
<p>
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:
</p>
<p>
𝛌 (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)
</p>
<p>
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.
</p>
TicketpumpkinTue, 15 Sep 2009 22:02:33 GMTcc set
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:6
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:6
<ul>
<li><strong>cc</strong>
<em>pumpkingod@…</em> added
</li>
</ul>
TicketbosTue, 22 Sep 2009 03:43:42 GMT
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:7
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:7
<p>
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.
</p>
TicketsimonmarMon, 16 Nov 2009 13:06:59 GMTdifficulty changed
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:8
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:8
<ul>
<li><strong>difficulty</strong>
changed from <em>Easy (1 hr)</em> to <em>Easy (less than 1 hour)</em>
</li>
</ul>
TicketporgesTue, 17 Nov 2009 01:03:51 GMTtype changed; failure set
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:9
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:9
<ul>
<li><strong>failure</strong>
set to <em>None/Unknown</em>
</li>
<li><strong>type</strong>
changed from <em>bug</em> to <em>feature request</em>
</li>
</ul>
<p>
I've been thinking that maybe even another arrow might work here, so that we have something like:
</p>
<pre class="wiki"> map (x ↦ f x) ys
</pre>
TicketsimonmarThu, 01 Apr 2010 15:28:17 GMTmilestone changed
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:10
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:10
<ul>
<li><strong>milestone</strong>
changed from <em>6.6.1</em> to <em>_|_</em>
</li>
</ul>
TicketlelfSun, 08 May 2011 22:05:11 GMTcc changed
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:11
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:11
<ul>
<li><strong>cc</strong>
<em>anton.nik@…</em> added
</li>
</ul>
TicketmorabbinMon, 21 Jan 2013 16:39:23 GMT
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:12
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:12
<p>
Seems like we're still at an impasses on this one: <tt>bos</tt>'s comment above is hard to get around.
</p>
TicketiglooTue, 22 Jan 2013 16:47:56 GMTstatus changed; resolution set
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:13
http://ghc.haskell.org/trac/ghc/ticket/1102#comment:13
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>wontfix</em>
</li>
</ul>
<p>
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.
</p>
Ticket