Is there any easy and fast way to type the funny characters (like ⊛, ≟, ∘, ∨ etc) from Scalaz? (I am using Ubuntu 9.04)
3 Answers
- Use the ASCII aliases provided by the library. For example,
|+|is an alias for⊹. - Use IntelliJ IDEA, with these Live Templates. You can then write
x mapmap<TAB>to getx ∘∘. Installation instructions are covered in this recent question. IntelliJ has a free Community Edition, and its my personal choice and recommendation for Scala coding. - I believe the shortcut in Gnome to enter an Unicode character is CTRL-SHIFT-U, Hex Code, Enter.
- Create templates for your favourite editor.
Why use these these symbols at all?
- We rely on the Pimp-my-Library pattern, but rather than wrapping one particular type, we provide extra functions that work for any type with suitable type class instances. Using non-standard characters minimises name clashes with methods provided by the original types.
- Some operations, like Functor map, Monadic bind, and Applicative Functor apply are really commonly used and fundamental. Scala builds some of these into the langauge with for-comprehensions. So we give you the option to use the Scalaz versions with a minimum of syntactic clutter, almost as though they were part of the language itself.
Example:
some(7) ∘ {1 +}
List(1, 2, 3) ∗ {x => List(7, x)}
case class Person(age: Int, name: String)
some(10) ⊛ none[String] apply Person.apply
Try this -
Make sure that numlock is OFF
Hold the ALT key
On the numeric pad - press + and then the decimal Unicode number of the character you want.
Release the ALT key
This is an old trick that worked in DOS with ASCII codes (without the +) and works in windows in edit boxes that take Unicode. It should work on some linuxes I think.
You may also want to try the method described here.
- 704
It's easier in Linux than in any other OS that I am aware of.
Check out this link for background/details: https://help.ubuntu.com/community/ComposeKey
First, you can hit Ctrl+Shift+U followed by with the Unicode code. For example, Ctrl+Shift+U + 2203 = ∃. That may not be so convenient, but you'll need it for the next step.
The better way is to use the compose key, AKA Multi_key. As described in the above article, you can compose characters with Multi_key + char1 + char2. For example, Multi_key ' e is é.
I find that the Caps Lock key makes a splendid Multi_key. You can set it with System Preferences -> Keyboard -> Layout -> Options.
To make your own compose key sequences. make a file ~/.XCompose and add entries such as
: "∃"
(using the Ctrl+Shift+U trick, or just with copy/paste)
Log out and in again (or, for testing, just run ssh -X localhost xterm).
- 101