Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Add mathematical/arrows unicode operator support #283

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fabianhjr
Copy link
Contributor

@fabianhjr fabianhjr commented Apr 15, 2020

Major change:

  • Support Mathematical Operators and Arrows as Symbols/Operators

From a commit in this repo:

While we're at it, Idris 1 supports unicode identifiers (although we don't encourage it :)) so this allows any characeter >127 in an identifier.

Though from Idris 1 FAQ [2013]:

Perhaps in a few years time things will be different and software will cope better and it will make sense to revisit this. For now, however, Idris will not be offering arbitrary Unicode symbols in operators.

This doesn't allow any arbitrary unicode, it adds the following 2 blocks:

This is a work in progress. I want to add a pragma or compiler option to enable this (So that this extra operators are opt-in) however since there is the possibility that unicode operators (even non-arbitrary) aren't desirable I would leave this as currently is for people to evaluate before implementing flags/pragmas to control this feature.

@fabianhjr fabianhjr changed the title Add unicode operator support Add mathematical/arrows unicode operator support Apr 15, 2020
@fabianhjr fabianhjr force-pushed the add-unicode-operator-support branch from e1912b8 to 74f97cc Compare April 15, 2020 13:50
@fabianhjr fabianhjr changed the title Add mathematical/arrows unicode operator support RFC: Add mathematical/arrows unicode operator support Apr 15, 2020
@fabianhjr fabianhjr changed the title RFC: Add mathematical/arrows unicode operator support WIP: Add mathematical/arrows unicode operator support Apr 15, 2020
@fabianhjr fabianhjr force-pushed the add-unicode-operator-support branch 6 times, most recently from c938889 to 19c46fa Compare April 20, 2020 04:38
@edwinb
Copy link
Owner

edwinb commented Apr 21, 2020

I know some people are keen on this sort of thing (I'm occasionally asked about it). Usually the reasoning is about wanting to make the code look more like the maths that's being modelled. It's a reasonable thing to want, although not something that Idris is generally targetted towards. So, I'm going to have to think about what has changed since the FAQ entry you refer to. I think it's right to revisit the issue, but I would still like to be careful.

The bug fix is definitely necessary - thanks for spotting that! Could it be in a PR on its own instead, though?

There are two things I'd definitely require:

  • At least for now, a flag to enable it (as you mention)
  • No unicode operators in any of the libraries distributed with Idris

I'm also a bit worried about what will happen to external library code, but I'd hope some reasonable conventions would emerge based on what the standard libraries do, and based on needing a flag to enable support.

@fabianhjr
Copy link
Contributor Author

Ah yes, the minor unicode identifier fixes are on #290, I forgot to put that in the PR description.

@fabianhjr fabianhjr force-pushed the add-unicode-operator-support branch from 19c46fa to 16c3efc Compare April 21, 2020 15:28
@fabianhjr fabianhjr changed the title WIP: Add mathematical/arrows unicode operator support RFC: Add mathematical/arrows unicode operator support Apr 21, 2020
@fabianhjr fabianhjr force-pushed the add-unicode-operator-support branch from 16c3efc to 923489e Compare April 21, 2020 18:19
@petithug
Copy link
Contributor

My 2 cents: As a software developer, the mathematical notation is puzzling -- there is no standard for that representation, and it is quite usual that math papers start by defining the notation that will be used in the rest of the paper.
Conversely in software engineering we are used that a name or symbol has one single meaning, at least per programming language.

So I think that it is fine that packages would choose to use a mathematical notation, using Unicode symbol or names, with the possibility of renaming names from the Prelude and Base packages as Unicode names and symbols. But to build on what Edwin said, I would forbid to use any Unicode name or symbol in the Prelude and Base, e.g. by adding a flag in the package ipkg that permits to verify this when parsed.

Then there would be the issue of the implication and equality symbols. Here I would define a directive to alias these, such as they could be renamed on a package per package basis.

@fabianhjr fabianhjr force-pushed the add-unicode-operator-support branch 3 times, most recently from 5c3e150 to f816000 Compare April 27, 2020 15:50
@petithug
Copy link
Contributor

petithug commented May 1, 2020

@nightscape
Copy link

nightscape commented May 1, 2020

As a side note: Scala allowed Unicode operators, but deprecated and now forbid them. The problem is that if person A starts with Unicode, but person B working on the same code cannot easily type them, you get a mix of both which is not nice.
Also, fonts with ligatures allow you to display operators in a nice looking fashion while still being just ordinary Ascii characters.

@fabianhjr fabianhjr marked this pull request as draft May 3, 2020 02:58
@fabianhjr fabianhjr force-pushed the add-unicode-operator-support branch 2 times, most recently from 136d3cd to 1db3aca Compare May 8, 2020 04:52
@fabianhjr fabianhjr force-pushed the add-unicode-operator-support branch from 1db3aca to e4245d4 Compare May 15, 2020 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants