Personal tools

Unicode-symbols

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(Removed fixities section, added in recent package release)
(Removed hlint problems section (fixed in hlint-1.6.21))
Line 42: Line 42:
 
But you can hardly call that an improvement over the simple:
 
But you can hardly call that an improvement over the simple:
 
not (not x) ≡ x
 
not (not x) ≡ x
 
====HLint problems====
 
 
[http://community.haskell.org/~ndm/hlint/ HLint] does not know about the fixities of the operators defined in *-unicode-symbols packages, and when run on a module containing an expression like
 
 
a == b ∧ c == d
 
 
HLint will immediately abort saying "hlint: Ambiguous infix expression".
 
 
So if being able to run your code through HLint is important to you, think twice about using *-unicode-symbols packages.
 
 
''Author note: This bug affects all fixities defined in other modules. I submitted a [http://code.google.com/p/ndmitchell/issues/detail?id=301 bug report] to the HLint issue tracker.''
 
   
 
====New symbol ideas==== (''please add your own'')
 
====New symbol ideas==== (''please add your own'')

Revision as of 13:39, 7 April 2010


Contents

1 Overview

An overview of the packages that provide Unicode symbols.

Naming: A package X-unicode-symbols defines new symbols for functions and operators from the package X.

All symbols are documented with their actual definition and information regarding their Unicode code point. They should be completely interchangeable with their definitions.

Alternatives for existing operators have the same fixity. New operators will have a suitable fixity defined.

1.1 UnicodeSyntax

GHC offers the UnicodeSyntax language extension. If you decide to use Unicode in your Haskell source then this extension can greatly improve how it looks.

2 base-unicode-symbols

Extra symbols for the base package.

 API docs: http://hackage.haskell.org/package/base-unicode-symbols
 darcs get http://code.haskell.org/~roelvandijk/code/base-unicode-symbols

2.1 Problematic symbols

Original Symbol Code point Name
not ¬ U+AC NOT SIGN

The problem with this symbol is that you would like to use it as a unary prefix operator:

 ¬(¬x) ≡ x

Unfortunately this is not valid Haskell. The following is:

 (¬)((¬)x) ≡ x

But you can hardly call that an improvement over the simple:

 not (not x) ≡ x

====New symbol ideas==== (please add your own)

3 containers-unicode-symbols

Extra symbols for the containers package.

 API docs: http://hackage.haskell.org/package/containers-unicode-symbols
 darcs get http://code.haskell.org/~roelvandijk/code/containers-unicode-symbols

====New symbol ideas==== (please add your own)

4 Input methods

These symbols are all very nice but how do you type them?

(please add info for other editors)

4.1 Emacs

Direct

Enter symbols directly: C-x 8 RET, then type either the character's name or its hexadecimal code point.

Custom script

 darcs get http://code.haskell.org/~roelvandijk/code/emacs-unicode-symbols

In your .emacs file:

 (load "~/elisp/emacs-unicode-symbols/haskell-symbols")
 (defun haskell-unicode () (local-set-key (kbd "C-M-u") 'replace-haskell-unicode))
 (add-hook 'haskell-mode-hook 'haskell-unicode)

With above hook installed navigate the point to right after a normal symbol like -> and press C-M-u to transform it into a beautiful .

Caveat: The author is an absolute Lisp newbie. Patches to above script are more than welcome.

Abbrev mode

The Abbrev mode is not suitable since it only deals with words, not operators.

Agda

Use Agda's input method.