stylish-haskell
stylish-haskell copied to clipboard
UnicodeSyntax
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.
I like that. If it also offers an option to perform the reverse translation then we'd have the best of both worlds. :-)
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.
I also like the idea, and it's not very hard to implement either (I think). Thanks for the suggestion!
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)
I can't reproduce the issue exactly, but I get errors as well, working on it.