unicoder: Make writing in unicode easy.

[ bsd3, library, program, text ] [ Propose Tags ]

Unicoder transforms text documents, replacing simple patterns with unicode equivalents. The patterns can be easily configured by the user. This package is especially meant to open the vast and expressive array of unicode identifiers to programmers and language designers, but there's nothing wrong with a technically savvy user putting unicoder to work on documents for human consumption.

With the default settings,

\E x. \A y. \<x \-> y\> \ldots
\l x,y. x \of x \of y

becomes

∃x ∀y ⟨x → y⟩ …
λ x,y. x ∘ x ∘ y

Many more possibilities abound just in the default set of characters. Any system of special characters can be made easy to type with a normal keyboard as long as unicode supports it.


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.4.0, 0.4.1, 0.5.0
Change log changes.md
Dependencies attoparsec (>=0.10.0.0), base (>=4.6 && <4.7), directory (>=1.2 && <1.3), text (>=0.11 && <0.12) [details]
License BSD-3-Clause
Copyright Copyright © 2013, 2014, Okuno Zankoku
Author Zankoku Okuno
Maintainer zankoku.okuno@gmail.com
Category Text
Source repo head: git clone https://github.com/Zankoku-Okuno/unicoder.git
Uploaded by ZankokuOkuno at 2014-07-12T18:33:03Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables unicoder
Downloads 2498 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for unicoder-0.4.0

[back to package description]

Unicoder

The unicoder reads in a source file and makes replacements in-place. The goal is to allow ascii interfaces to be able to insert unicode without taking your hands off the keyboard. This can allow for unicode to be entered into source code or any other text document you're editing.

Entering unicode is not as easy as typing a special string (default backslash) followed by an identifier. There's also syntax for wrapping content inside a pair of unicode strings. For example, with the default configuration, unicoder turns \floor{x} \def \lambda x. (floor x) into ⌊x⌋ ≡ λ x. (floor x). Admitedly, this is not a great syntax for some kinds of documents (esp. XeLaTeX), but that's why we've allowed for configuration of each of the special marks as well as the identifier character set, so Unicoder can be relevant to any type of text data.

There's a detailed explanation of the unicoder algorithm and configuration on our Viewdocs. It's fairly likely that the system can be deduced just from examples, though.

Examples

Assuming a config file that looks like this:

\ . { } a-z

lambda λ
pi π
bag ⟅ ⟆

we can write this with a normal keyboard:

\lambda.x. x + \pi

and after unicodizing, we will get:

λx. x + π

and celebrate the nice, clean lambda-calculus.

Have no fear, however, code such as this:

id = \x -> x
newline_period = "\n."

Will remain unchanged, as x and n are not in the config file.

There are also two-part replacements. These take a single (non-nested) argument, transforming

\bag{black}

into

⟅black⟆

You can also use each half of a two-part replacement individually. This is especially usefule for nesting, but also when you simply have argument-close marks in the argument:

\{bag {} \}bag

becomes

⟅ {} ⟆

Pitfalls

Even in something as simple as this, you may want to be aware of a few facts:

  • Beware of adding names like n or t in your config file. If you are using a language that isn't esoteric, you will probably change the meaning of your code.
  • It is still possible to mess up strings. For example, "\neq""≠" instead of being equivalent to "\n" ++ "eq". I conjecture that there is no way to solve this problem without sacrificing idempotence.
  • I've made little attempt to ensure safety, other than using Haskell. Make backups if you are wary (and your editor doesn't already).

Thankfully, the pitfalls are realistically enumerable.