https://wiki.haskell.org/api.php?action=feedcontributions&user=Eelis&feedformat=atomHaskellWiki - User contributions [en]2024-03-28T10:22:23ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Unicode-symbols&diff=34412Unicode-symbols2010-04-05T18:36:33Z<p>Eelis: Warn about HLint problems</p>
<hr />
<div>[[Category:Packages]]<br />
<br />
== Overview ==<br />
<br />
An overview of the packages that provide Unicode symbols. <br />
<br />
Naming: A package '''<tt>X-unicode-symbols</tt>''' defines new symbols for functions and operators from the package '''<tt>X</tt>'''.<br />
<br />
All symbols are documented with their actual definition and information regarding their Unicode code point. They should be completely interchangeable with their definitions.<br />
<br />
Alternatives for existing operators have the same fixity. New operators will have a suitable fixity defined.<br />
<br />
==== UnicodeSyntax ====<br />
<br />
GHC offers the [http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#unicode-syntax UnicodeSyntax] language extension. If you decide to use Unicode in your Haskell source then this extension can greatly improve how it looks.<br />
<br />
== base-unicode-symbols ==<br />
<br />
Extra symbols for the [http://hackage.haskell.org/package/base base] package.<br />
<br />
API docs: http://hackage.haskell.org/package/base-unicode-symbols<br />
<br />
darcs get http://code.haskell.org/~roelvandijk/code/base-unicode-symbols<br />
<br />
====Problematic symbols====<br />
{| class="wikitable" border="1"<br />
|-<br />
! Original<br />
! Symbol<br />
! Code point<br />
! Name<br />
|-<br />
| not<br />
| &#xAC;<br />
| U+AC<br />
| NOT SIGN<br />
|}<br />
The problem with this symbol is that you would like to use it as a unary prefix operator:<br />
&not;(&not;x) &equiv; x<br />
Unfortunately this is not valid Haskell. The following is:<br />
(&not;)((&not;)x) &equiv; x<br />
But you can hardly call that an improvement over the simple:<br />
not (not x) &equiv; x<br />
<br />
====HLint problems====<br />
<br />
[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<br />
<br />
a == b ∧ c == d<br />
<br />
HLint will immediately abort saying "hlint: Ambiguous infix expression".<br />
<br />
So if being able to run your code through HLint is important to you, think twice about using *-unicode-syntax packages.<br />
<br />
====New symbol ideas==== (''please add your own'')<br />
<br />
== containers-unicode-symbols ==<br />
<br />
Extra symbols for the [http://hackage.haskell.org/package/containers containers] package.<br />
<br />
API docs: http://hackage.haskell.org/package/containers-unicode-symbols<br />
<br />
darcs get http://code.haskell.org/~roelvandijk/code/containers-unicode-symbols<br />
<br />
==== Fixities ====<br />
<br />
What should the fixities for the following symbols be?<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! Symbol<br />
! Code point<br />
! Name<br />
|-<br />
| &cup;<br />
| U+222A<br />
| UNION<br />
|-<br />
| &cap;<br />
| U+2229<br />
| INTERSECTION<br />
|-<br />
| &sube;<br />
| U+2286<br />
| SUBSET OF OR EQUAL TO<br />
|-<br />
| &supe;<br />
| U+2287<br />
| SUPERSET OF OR EQUAL TO <br />
|-<br />
| &#x2288;<br />
| U+2288<br />
| NEITHER A SUBSET OF NOR EQUAL TO <br />
|-<br />
| &#x2289;<br />
| U+2289<br />
| NEITHER A SUPERSET OF NOR EQUAL TO <br />
|-<br />
| &sub;<br />
| U+2282<br />
| SUBSET OF <br />
|-<br />
| &sup;<br />
| U+2283<br />
| SUPERSET OF <br />
|-<br />
| &#x2284;<br />
| U+2284<br />
| NOT A SUBSET OF <br />
|-<br />
| &#x2285;<br />
| U+2285<br />
| NOT A SUPERSET OF <br />
|}<br />
<br />
Intuitively there is a correspondence with numerical operators. Compare the following operators:<br />
<br />
{| class="wikitable" border="1"<br />
| &#x222A;<br />
| +<br />
|-<br />
| &#x2283;<br />
| ><br />
|-<br />
| &#x2284;<br />
| &#x226E;<br />
|}<br />
<br />
Likewise you would like similar associativities and precedence levels:<br />
<br />
<haskell><br />
x + y + z < w == ((x + y) + z) < w<br />
x ∪ y ∪ w ⊂ z == ((x ∪ y) ∪ z) ⊂ w<br />
</haskell><br />
<br />
====New symbol ideas==== (''please add your own'')<br />
<br />
== Input methods ==<br />
<br />
These symbols are all very nice but how do you type them?<br />
<br />
(''please add info for other editors'')<br />
<br />
=== Emacs ===<br />
<br />
'''Direct'''<br />
<br />
Enter symbols directly: <tt>[http://www.gnu.org/software/emacs/manual/html_node/emacs/International-Chars.html C-x 8 RET]</tt>, then type either the character's name or its hexadecimal code point.<br />
<br />
'''Custom script'''<br />
<br />
darcs get http://code.haskell.org/~roelvandijk/code/emacs-unicode-symbols<br />
<br />
In your .emacs file:<br />
(load "~/elisp/emacs-unicode-symbols/haskell-symbols")<br />
(defun haskell-unicode () (local-set-key (kbd "C-M-u") 'replace-haskell-unicode))<br />
(add-hook 'haskell-mode-hook 'haskell-unicode)<br />
<br />
With above hook installed navigate the point to right after a normal symbol like '''->''' and press '''<tt>C-M-u</tt>''' to transform it into a beautiful '''&rarr;'''.<br />
<br />
''Caveat'': The author is an absolute Lisp newbie. Patches to above script are more than welcome.<br />
<br />
'''Abbrev mode'''<br />
<br />
The [http://www.gnu.org/software/emacs/manual/html_node/emacs/Abbrevs.html Abbrev mode] is not suitable since it only deals with ''words'', not ''operators''.<br />
<br />
'''Agda'''<br />
<br />
Use Agda's [http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Docs.UnicodeInput input method].</div>Eelis