Unicode silliness

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Unicode silliness

David Turner-2
Hi,

One of my colleagues asked about using Unicode symbols in Haskell operators and I initially thought that this was supported.

However, the code at the bottom of this message doesn't parse, reporting a lexical error on basically all of the funny characters of the form:

Main.hs:1:5: error: lexical error at character '\65288'

Character 65288 (0xff08) is punctuation [Ps] which I understand to mean it counts as a uniSymbol in the lexical structure described in the Haskell Report.


Should this work? Not that I really want this specific example to work, but I'm interested to know why.

Many thanks,

David


$ cat app/Main.hs
foo (›’-’)› bar = False
foo ‹(’-’‹) bar = False
foo ∧(’-’)∧ bar = False
foo ∨(’-’)∨ bar = False
$ cat app/Main.hs | base64 # try and avoid mangling in email
Zm9vIO+8iOKAuuKAmS3igJnvvInigLogYmFyID0gRmFsc2UKZm9vIOKAue+8iOKAmS3igJnigLnv
vIkgYmFyID0gRmFsc2UKZm9vIOKIp++8iOKAmS3igJnvvIniiKcgYmFyID0gRmFsc2UKZm9vIOKI
qO+8iOKAmS3igJnvvIniiKggYmFyID0gRmFsc2UK



_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unicode silliness

MarLinn
> foo (›’-’)› bar = False
>
> Main.hs:1:5: error: lexical error at character '\65288'

Brackets.

To see unicode operators in action, take a look at
https://hackage.haskell.org/package/base-unicode-symbols
and
https://hackage.haskell.org/package/acme-flipping-tables

Cheers.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unicode silliness

David Turner-2
On 13 July 2017 at 12:58, MarLinn <[hidden email]> wrote:
foo (›’-’)› bar = False

Main.hs:1:5: error: lexical error at character '\65288'

Brackets.

Yes, brackets, but why is this a problem?

I found this code [1] in GHC which seems like it might be relevant. Is it? It seems to suggest that classes Pc, Pd, Po, Sm, Sc, Sk and So are allowed in infix names, but Ps, Pe, Pi and Pf are not. Am I reading that right?


Cheers,

David



_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unicode silliness

Clinton Mead
I think MarLinn was highlighting that this line:

> foo ‹(’-’‹) bar = False

Should read like this:

> foo ‹(’-’) bar = False

On Fri, Jul 14, 2017 at 1:03 AM, David Turner <[hidden email]> wrote:
On 13 July 2017 at 12:58, MarLinn <[hidden email]> wrote:
foo (›’-’)› bar = False

Main.hs:1:5: error: lexical error at character '\65288'

Brackets.

Yes, brackets, but why is this a problem?

I found this code [1] in GHC which seems like it might be relevant. Is it? It seems to suggest that classes Pc, Pd, Po, Sm, Sc, Sk and So are allowed in infix names, but Ps, Pe, Pi and Pf are not. Am I reading that right?


Cheers,

David



_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unicode silliness

David Turner-2

On 13 July 2017 at 16:13, Clinton Mead <[hidden email]> wrote:
I think MarLinn was highlighting that this line:
> foo ‹(’-’‹) bar = False

Should read like this: 
> foo ‹(’-’) bar = False

That doesn't seem to help, unfortunately. It says:

> Main.hs:1:5: error: lexical error at character '\8249'



_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unicode silliness

Clinton Mead
And also:

> foo (›’-’)› bar = False

should be

> foo (’-’)› bar = False

I'd suggest ensuring your code compiles without the unicode first, before trying to add the unicode symbols, so you can be sure it's the unicode causing the problem.

On Fri, Jul 14, 2017 at 1:17 AM, David Turner <[hidden email]> wrote:

On 13 July 2017 at 16:13, Clinton Mead <[hidden email]> wrote:
I think MarLinn was highlighting that this line:
> foo ‹(’-’‹) bar = False

Should read like this: 
> foo ‹(’-’) bar = False

That doesn't seem to help, unfortunately. It says:

> Main.hs:1:5: error: lexical error at character '\8249'




_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unicode silliness

David Turner-2

On 13 July 2017 at 16:20, Clinton Mead <[hidden email]> wrote:
And also:

> foo (›’-’)› bar = False

should be

> foo (’-’)› bar = False

I'd suggest ensuring your code compiles without the unicode first, before trying to add the unicode symbols, so you can be sure it's the unicode causing the problem.


It does. This is fine:

> foo ?!?!?!? bar = False

It's the Unicode punctuation that isn't. Note that the things that look like parentheses aren't ASCII parentheses, they're U+FF08 FULLWIDTH LEFT PARENTHESIS and U+FF09 FULLWIDTH RIGHT PARENTHESIS, which are in classes Ps and Pe respectively, and the code I linked to earlier seems to dislike those classes.

Cheers,

David



_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Loading...