[Haskell-cafe] Unicode Haskell source -- Yippie!
Niklas Hambüchen
mail at nh2.me
Thu Apr 24 21:07:57 UTC 2014
A smart, recently proposed alternative is using a font that does this
automatically for you: https://github.com/i-tu/Hasklig
In my opinion, this gives you all benefits of unicode syntax without
imposing the drawbacks on others, and you don't even have to set up a
custom input method to conveniently type them in.
Quoting:
Some Haskell programmers have resorted to unicode symbols in code as a
solution (⇒, ← etc.). This opens a whole new can of worms. In addition
to encoding/compatibility problems and all the reasons it never worked
out for APL, these symbols are one-character-wide and therefore
eye-strainingly small.
Hasklig solves this problem the way typographers have always solved
ill-fitting characters which co-occur often: ligatures. The underlying
code stays the same — only the representation changes.
On Thu 24 Apr 2014 21:02:30 BST, Tikhon Jelvis wrote:
> 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 <mailto: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 <mailto:Haskell-Cafe at haskell.org>
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list