[Haskell-cafe] Unicode Haskell source -- Yippie!

Tikhon Jelvis tikhon at jelv.is
Thu Apr 24 20:02:30 UTC 2014


I'm actually a fan of using Unicode in my code. As people like to say, code
is read more often than it's written, so I'm willing to make typing a bit
harder in return for making the code prettier.

Happily, typing Unicode characters is quite easy with a good editor
(Emacs). I use the TeX input mode which just lets me use TeX names for
symbols, but somebody has actually written a Haskell-specific mode which
might be even better[1]. I might try it some day.

One peculiar habit I have is using x₁ x₂ x₃ instead of x1, x2, x3 or x_1,
x_2, x_3. I definitely find the Unicode version easier to read and work
with, although it probably helps that Emacs highlights the number in a
different color.

Unfortunately, this is a minority opinion at the moment. Even in *this* day
and age, people still find Unicode too difficult to type!

For my internal code, this is not a problem, but it's kept me from putting
any Unicode in public APIs. Shame.

I also don't use UnicodeSyntax because Emacs can do most of the
transformations transparently for me without changing the underlying file.
You can turn this on by setting `haskell-font-lock-symbols' to t. I find it
makes for much nicer code that's easier to read and, even more importantly,
easier to skim.

[1]: https://github.com/roelvandijk/emacs-haskell-unicode-input-method


On Thu, Apr 24, 2014 at 12:51 PM, Roel van Dijk <vandijk.roel at gmail.com>wrote:

> I think it is a nice feature if used sparingly.
>
> Note that while Unicode symbols are a normal part of the Haskell language
> you can also turn on some Unicode syntax using the UnicodeSyntax [1]
> language extension. This means the following will be accepted by GHC:
>
> (∈) ∷ ∀ α. Eq α ⇒ α → [α] → Bool
> (∈) = elem
>
> You might want to take a look at some packages I created that define some
> Unicode symbols for common operators and values [2, 3, 4].
>
> Opinions on whether this is a good idea vary. My anecdotal observation is
> that it seems to be used more by people who speak a native language that is
> already poorly served by ASCII. Perhaps because they are already used to
> not being able to simply type every character they need.
>
> 1 -
> http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#unicode-syntax
> 2 - http://www.haskell.org/haskellwiki/Unicode-symbols
> 3 - http://hackage.haskell.org/package/base-unicode-symbols
> 4 - http://hackage.haskell.org/package/containers-unicode-symbols
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140424/35e14380/attachment.html>


More information about the Haskell-Cafe mailing list