Is there any easy and fast way to type the funny characters (like ⊛, ≟, ∘, ∨ etc) from Scalaz? (I am using Ubuntu 9.04)
-
4I seriously cannot understand why the library designers chose to use such funny symbols in first place. Any valid reasons? – May 02 '10 at 05:32
-
2Agreed, until we see some keyboard support at least – May 02 '10 at 05:42
-
There is a great amount of ways to print funny characters, but most of them are OS- and distro-specific. I think such questions should be better asked on superuser. – P Shved May 02 '10 at 06:06
-
1@Pavel: I am expecting answers from creators of Scalaz themselves. That's why I posted the question on StackOverflow. – May 02 '10 at 07:14
-
Have a look at xmodmap. – Debilski May 02 '10 at 08:06
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
-
-
1Can you recommend any programming fonts that cover all of those Unicode characters? - Personally, I would like to use a font that has variable-width characters (I don't align my code in columns any more), but unfortunately, IntelliJ IDEA can only handle cursor movement well for fixed-width fonts. – Madoc Aug 17 '11 at 09:12
-
this is a bit out of scope, but why the special characters (or even |+|), what's wrong with giving a meaningful name to the function? I am trying to get into scalaz, but everytime I see an example with `some(7) ∘ {1 +}`, it's just impossible to understand what that is meant to do. You could argue that its to save keystrokes, but if you have to type "mapmap
" to get the right character, why not just call the function mapmap? – Mortimer Mar 22 '13 at 18:54
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.
- 694
- 1
- 10
- 16
-
2This is not something I'd call rapid. And I cannot remember unicode numbers of so many characters. I'm looking for something quicker and less demanding. – May 02 '10 at 07:15
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
- 3