Skip to content

UnicodeSyntax #3

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

Open
jameshfisher opened this issue May 29, 2012 · 5 comments
Open

UnicodeSyntax #3

jameshfisher opened this issue May 29, 2012 · 5 comments

Comments

@jameshfisher
Copy link

GHC has an extension called UnicodeSyntax that lets you use unicode symbols for various keywords in the Haskell syntax. It would be nice if I could automatically UnicodeSyntaxify code. This would involve adding the extension at the top of the module if not already there, and replacing all replaceable symbols with their unicode counterparts.

@meiersi
Copy link

meiersi commented May 29, 2012

I like that. If it also offers an option to perform the reverse translation then we'd have the best of both worlds. :-)

@meiersi
Copy link

meiersi commented May 29, 2012

Note that an alternative way is to use https://github.com/frerich/unicode-haskell. It is especially nice as it converts data back to ASCII upon saving and converts characters as you type.

@jaspervdj
Copy link
Member

I also like the idea, and it's not very hard to implement either (I think). Thanks for the suggestion!

@JPMoresmau
Copy link

This seems to exist in the latest version, but fails on a module that contains text to translate.

Given the module:

module Folder1.JP1 where

t1 :: String
t1="test"

And the config file:

steps:
- unicode_syntax:
    add_language_pragma: false
- imports:
    align: global
- language_pragmas:
    style: vertical
    remove_redundant: true
- trailing_whitespace: {}

It fails with:

Enabled UnicodeSyntax step
Enabled Imports step
Enabled LanguagePragmas step
Enabled TrailingWhitespace step
stylish-haskell: StylishHaskell.Parse.parseModule: could not parse JP1.hs: Parse
Failed (SrcLoc {srcFilename = "<unknown>.hs", srcLine = 5, srcColumn = 1}) "TemplateHaskell is not enabled"

If I set add_language_pragma to true, I get:

stylish-haskell: JP1.hs: commitBuffer: invalid argument (character is not in the code page)

If first I do save the module in UTF-8 (via notepad in Windows, so I'd say a BOM is added:

stylish-haskell: StylishHaskell.Parse.parseModule: could not parse JP1.hs: Parse
Failed (SrcLoc {srcFilename = "<unknown>.hs", srcLine = 1, srcColumn = 1}) "Parse error: \180\9559\9488"

More importantly, any of these errors cause the file to be erased totally!

On a module that does not contains text sequences, there are no errors. (Nothing is done, which I suppose explains it)

@jaspervdj
Copy link
Member

I can't reproduce the issue exactly, but I get errors as well, working on it.

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

4 participants