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

[Discussion] Character class for apostrophe #549

Closed
gracjan opened this issue Mar 24, 2015 · 5 comments
Closed

[Discussion] Character class for apostrophe #549

gracjan opened this issue Mar 24, 2015 · 5 comments

Comments

@gracjan
Copy link
Contributor

gracjan commented Mar 24, 2015

Apostrophe is seriously overloaded character in Haskell. Here it goes:

  • 'x', 'X' - a char constant
  • 'xf' - Template Haskell Name for xf'
  • ''XF' - Template Haskell Type for XF'
  • '\1231' - a char constant
  • '\SOH' - a char constant
  • '' - illegal, somewhat char
  • '1x' - illegal
  • '''XF - illegal

So apostrophe is a:

  • symbol constituent (xf')
  • string quote ('x')
  • expression prefix ('xf ''XF)
  • illegal

Most of the above can be fixed by syntax-propertize. There are two questions though:

  • what should be the default syntax class for apostrophe?
  • what should be the syntax class for apostrophe in illegal cases?
  • should apostrophe that is part of identifiers have syntax class _ or w?
@ivan-m
Copy link
Contributor

ivan-m commented Mar 25, 2015

Don't forget also that x'f is also a valid variable/function name (so ' isn't just a symbol constituent at the end).

@gracjan
Copy link
Contributor Author

gracjan commented Mar 26, 2015

Proposition is:

  • default for apostrophe is punctuation
  • illegal apostrophe is punctuation
  • apostrophe in identifiers is same class as underscore, that is 'w'

@gracjan
Copy link
Contributor Author

gracjan commented Apr 4, 2015

Some more testing:

Prelude> (,) 'x''y'
('x','y')
Prelude> (,) 12'y'
(12,'y')
Prelude> (,) 0x12'y'
(18,'y')
Prelude> (,) x12'y'
<interactive>:6:5: Not in scope: ‘x12'y'’
Prelude> (,) 'x''y''
<interactive>:7:12:
    lexical error in string/character literal at end of input
Prelude> let y = 45
Prelude> (,) 'x'y
('x',45)
Prelude> (,) 'x''y
('x',y_1627393257)
Prelude> (,) "x"'y'
("x",'y')
Prelude> (,) 'y'"x"
('y',"x")
Prelude> (,) '"'"'"
('"',"'")
Prelude> (,) 12e-34'r'
(1.2e-33,'r')
Prelude> (,) 12.34'r'
(12.34,'r')

@gracjan
Copy link
Contributor Author

gracjan commented May 4, 2015

And apostrophe for DataKinds and TemplateHaskell is prefix operator class.

@gracjan gracjan changed the title Character class for apostrophe [Discussion] Character class for apostrophe Aug 30, 2015
@gracjan
Copy link
Contributor Author

gracjan commented Jan 31, 2016

This is more or less fixed in the new syntax-propertize0-function.

@gracjan gracjan closed this as completed Jan 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants