A rapid way to type funny characters from Scalaz?
Is there any easy and fast way to type the funny characters (like ⊛, ≟, ∘, ∨ etc) from Scalaz? (I am using Ubuntu 9.04)
- 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