|
|
**Ticket:**[\#20](https://gitlab.haskell.org//haskell/prime/issues/20)
|
|
|
|
|
|
|
|
|
|
## Eliminate . as an operator
|
|
## Eliminate . as an operator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In early Haskell, . was used as function composition. In later versions of Haskell, it also became used as a name qualifier.
|
|
In early Haskell, . was used as function composition. In later versions of Haskell, it also became used as a name qualifier.
|
|
|
|
|
|
|
|
|
|
|
|
|
These two uses do not fit well together, leading to special lexical rules (P11 of the report). As a test, before reading the report, can you lex the following: "f.g", "F.g", "F . g", "f..", "F..", and "F.". I couldn't.
|
|
|
|
|
(See [QualifiedIdentifiers](qualified-identifiers) for a related problem.)
|
|
|
|
|
|
|
|
|
|
|
These two uses do not fit well together, leading to special lexical rules (P11 of the report). As a test, before reading the report, can you lex the following: "f.g", "F.g", "F . g", "f..", "F..", and "F.". I couldn't.
|
|
|
|
|
|
|
|
Proposed syntaxes for [RankNTypes](rank-n-types) and [ExistentialQuantification](existential-quantification) also use . as a special symbol.
|
|
|
|
|
|
|
|
|
|
## Proposal
|
|
## Proposal
|
|
|
|
|
|
|
|
- Add `.` to *reservedop* in the lexical syntax
|
|
|
|
|
- move qualified identifiers (`qvarid`, `qconid` etc.) from the lexical syntax to the context-free syntax
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(Note: `.` also appears in the syntax as a decimal point in floats).
|
|
Reserve . for use as a qualifier in names. Do not permit . as an operator symbol. (Also continue to permit it as a decimal point in floats).
|
|
|
|
|
|
|
|
|
|
|
|
## Pros
|
|
## Pros
|
|
|
|
|
|
|
|
- Much much simpler. Not impossible to remember.
|
|
|
|
|
- Paves the way for using `.` as the selection operator in improved record or module systems
|
|
|
|
|
|
Much much simpler. Not impossible to remember.
|
|
|
|
|
|
|
|
|
|
|
|
## Cons
|
|
## Cons
|
|
|
|
|
|
|
|
- We lose . as composition. Mostly this doesn't matter as $ is probably more common in reality anyway (a highly controversial view, unsupported by evidence!). Perhaps use
|
|
|
|
|
``o`` as infix composition instead if it is really important. Note that ``o`` is three characters - it
|
|
|
|
|
would be nicer to use plain `o` infix, but that would require another special lexical rule. Others alternatives
|
|
|
|
|
for composition include [Unicode](unicode) symbols such as centred-dot ·, a bullet point •, an unfilled bullet point, the ring operator (U+2218), the
|
|
|
|
|
degree sign °, the masculine ordinal indicator º, stroked circle ø, and so on. All of these resemble the mathematical
|
|
|
|
|
symbol, and some of them are available in the Latin-1 subset.
|
|
|
|
|
|
|
|
|
|
- Breaks quite a lot of code |
|
- We lose . as composition. Mostly this doesn't matter as $ is probably more common in reality anyway. Perhaps use `o` as infix composition instead if it is really important.
|
|
|
|
- We need to make a special case of .. in the \[m .. n\] case. |