Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share
4  
I seriously cannot understand why the library designers chose to use such funny symbols in first place. Any valid reasons? –  Green Hyena May 2 '10 at 5:32
2  
Agreed, until we see some keyboard support at least –  Pierreten May 2 '10 at 5: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. –  Pavel Shved May 2 '10 at 6:06
1  
@Pavel: I am expecting answers from creators of Scalaz themselves. That's why I posted the question on StackOverflow. –  Green Hyena May 2 '10 at 7:14
    
Have a look at xmodmap. –  Debilski May 2 '10 at 8:06
add comment

migrated from stackoverflow.com May 2 '10 at 12:03

This question came from our site for professional and enthusiast programmers.

3 Answers

  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
share
    
Didn't know about Live Templates. Thanks. –  Green Hyena May 2 '10 at 8:06
1  
Can 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 9: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<TAB>" to get the right character, why not just call the function mapmap? –  Mortimer Mar 22 '13 at 18:54
add comment

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.

share
2  
This 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. –  Green Hyena May 2 '10 at 7:15
add comment

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

share
add comment

This site is currently not accepting new answers.