A rapid way to type funny characters from Scalaz?

13

4

Is there any easy and fast way to type the funny characters (like ⊛, ≟, ∘, ∨ etc) from Scalaz? (I am using Ubuntu 9.04)

Green Hyena

Posted 2010-05-02T05:31:24.330

Reputation:

4I seriously cannot understand why the library designers chose to use such funny symbols in first place. Any valid reasons? – None – 2010-05-02T05:32:36.170

2Agreed, until we see some keyboard support at least – None – 2010-05-02T05:42:42.770

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 – 2010-05-02T06:06:21.750

1@Pavel: I am expecting answers from creators of Scalaz themselves. That's why I posted the question on StackOverflow. – None – 2010-05-02T07:14:00.260

Have a look at xmodmap. – Debilski – 2010-05-02T08:06:15.637

Answers

12

  1. Use the ASCII aliases provided by the library. For example, |+| is an alias for .
  2. Use IntelliJ IDEA, with these Live Templates. You can then write x mapmap<TAB> to get x ∘∘. Installation instructions are covered in this recent question. IntelliJ has a free Community Edition, and its my personal choice and recommendation for Scala coding.
  3. I believe the shortcut in Gnome to enter an Unicode character is CTRL-SHIFT-U, Hex Code, Enter.
  4. Create templates for your favourite editor.

Why use these these symbols at all?

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

retronym

Posted 2010-05-02T05:31:24.330

Reputation: 221

Didn't know about Live Templates. Thanks. – None – 2010-05-02T08:06:20.453

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 – 2011-08-17T09:12:15.243

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<TAB>" to get the right character, why not just call the function mapmap? – Mortimer – 2013-03-22T18:54:01.077

0

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.

shoosh

Posted 2010-05-02T05:31:24.330

Reputation: 624

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. – None – 2010-05-02T07:15:20.790

0

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

cayhorstmann

Posted 2010-05-02T05:31:24.330

Reputation: 101