# Difference between revisions of "Unicode-symbols"

Roelvandijk (talk | contribs) (More content (work in progress)) |
Roelvandijk (talk | contribs) (Fixities, input method) |
||

Line 14: | Line 14: | ||

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. |
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. |
||

− | |||

− | ==== Input methods ==== |
||

− | |||

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

− | |||

− | TODO |
||

== base-unicode-symbols == |
== base-unicode-symbols == |
||

Line 25: | Line 19: | ||

Extra symbols for the [http://hackage.haskell.org/package/base base] package. |
Extra symbols for the [http://hackage.haskell.org/package/base base] package. |
||

− | API docs: http://hackage.haskell.org/package/base-unicode-symbols |
+ | API docs: http://hackage.haskell.org/package/base-unicode-symbols |

− | darcs get http://code.haskell.org/~roelvandijk/code/base-unicode-symbols |
+ | darcs get http://code.haskell.org/~roelvandijk/code/base-unicode-symbols |

− | ====New symbol ideas==== (please add your own) |
+ | ====New symbol ideas==== (''please add your own'') |

{| class="wikitable" border="1" |
{| class="wikitable" border="1" |
||

|- |
|- |
||

Line 47: | Line 41: | ||

Extra symbols for the [http://hackage.haskell.org/package/containers containers] package. |
Extra symbols for the [http://hackage.haskell.org/package/containers containers] package. |
||

− | API docs: http://hackage.haskell.org/package/containers-unicode-symbols |
+ | API docs: http://hackage.haskell.org/package/containers-unicode-symbols |

− | darcs get http://code.haskell.org/~roelvandijk/code/containers-unicode-symbols |
+ | darcs get http://code.haskell.org/~roelvandijk/code/containers-unicode-symbols |

==== Fixities ==== |
==== Fixities ==== |
||

Line 61: | Line 55: | ||

! Name |
! Name |
||

|- |
|- |
||

− | | & |
+ | | ∪ |

| U+222A |
| U+222A |
||

| UNION |
| UNION |
||

|- |
|- |
||

− | | & |
+ | | ∩ |

| U+2229 |
| U+2229 |
||

| INTERSECTION |
| INTERSECTION |
||

|- |
|- |
||

− | | & |
+ | | ⊆ |

| U+2286 |
| U+2286 |
||

| SUBSET OF OR EQUAL TO |
| SUBSET OF OR EQUAL TO |
||

|- |
|- |
||

− | | & |
+ | | ⊇ |

| U+2287 |
| U+2287 |
||

| SUPERSET OF OR EQUAL TO |
| SUPERSET OF OR EQUAL TO |
||

Line 85: | Line 79: | ||

| NEITHER A SUPERSET OF NOR EQUAL TO |
| NEITHER A SUPERSET OF NOR EQUAL TO |
||

|- |
|- |
||

− | | & |
+ | | ⊂ |

| U+2282 |
| U+2282 |
||

| SUBSET OF |
| SUBSET OF |
||

|- |
|- |
||

− | | & |
+ | | ⊃ |

| U+2283 |
| U+2283 |
||

| SUPERSET OF |
| SUPERSET OF |
||

Line 117: | Line 111: | ||

Likewise you would like similar associativities and precedence levels: |
Likewise you would like similar associativities and precedence levels: |
||

− | <tt> |
||

+ | <haskell> |
||

x + y + z < w == ((x + y) + z) < w |
x + y + z < w == ((x + y) + z) < w |
||

− | x |
+ | x ∪ y ∪ w ⊂ z == ((x ∪ y) ∪ z) ⊂ w |

+ | </haskell> |
||

+ | |||

+ | ====New symbol ideas==== (''please add your own'') |
||

+ | |||

+ | |||

+ | == Input methods == |
||

+ | |||

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

+ | |||

+ | (''please add info for other editors'') |
||

+ | |||

+ | === Emacs === |
||

+ | |||

+ | '''Direct''' |
||

+ | |||

+ | 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. |
||

+ | |||

+ | '''Custom script''' |
||

+ | |||

+ | http://code.haskell.org/~roelvandijk/code/emacs-unicode-symbols |
||

+ | |||

+ | In your .emacs file: |
||

+ | <tt> |
||

+ | (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) |
||

</tt> |
</tt> |
||

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

+ | 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 '''→'''. |
||

+ | |||

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

+ | |||

+ | '''Abbrev mode''' |
||

+ | |||

+ | 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''. |
||

+ | |||

+ | '''Agda''' |
||

+ | |||

+ | Use Agda's [http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Docs.UnicodeInput input method]. |

## Revision as of 13:03, 23 March 2010

## Contents

## 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.

#### 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.

## 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

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

Original | Symbol | Code point | Name |
---|---|---|---|

Control.Monad.>> | ≫ | U+226B | MUCH GREATER-THAN |

## 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

#### Fixities

What should the fixities for the following symbols be?

Symbol | Code point | Name |
---|---|---|

∪ | U+222A | UNION |

∩ | U+2229 | INTERSECTION |

⊆ | U+2286 | SUBSET OF OR EQUAL TO |

⊇ | U+2287 | SUPERSET OF OR EQUAL TO |

⊈ | U+2288 | NEITHER A SUBSET OF NOR EQUAL TO |

⊉ | U+2289 | NEITHER A SUPERSET OF NOR EQUAL TO |

⊂ | U+2282 | SUBSET OF |

⊃ | U+2283 | SUPERSET OF |

⊄ | U+2284 | NOT A SUBSET OF |

⊅ | U+2285 | NOT A SUPERSET OF |

Intuitively there is a correspondence with numerical operators. Compare the following operators:

∪ | + |

⊃ | > |

⊄ | ≮ |

Likewise you would like similar associativities and precedence levels:

```
x + y + z < w == ((x + y) + z) < w
x ∪ y ∪ w ⊂ z == ((x ∪ y) ∪ z) ⊂ w
```

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

## Input methods

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

(*please add info for other editors*)

### Emacs

**Direct**

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

**Custom script**

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.