Skip to content
A tool for changing code across many languages.
OCaml Shell Standard ML Dockerfile Makefile C
Branch: master
Clone or download
Latest commit 9b77fb8 Nov 6, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update Sep 18, 2019
dockerfiles Add ubuntu binary docker release and update script (#132) Nov 6, 2019
docs update roadmap issue Oct 8, 2019
scripts Add ubuntu binary docker release and update script (#132) Nov 6, 2019
src bump version 0.11.0 Nov 6, 2019
test Separate Javascript and Typescript and handle .tsx and .jsx (#130) Nov 6, 2019
.dockerignore Remove lambda-term Sep 26, 2019
.gitignore Add interactive mode Sep 24, 2019 Add interactive mode Sep 24, 2019
.travis.ocaml.yml Add docker files and scripts and update travis with docker build Jun 6, 2019
.travis.yml Simplify dockerfiles (#131) Nov 6, 2019
Dockerfile Simplify dockerfiles (#131) Nov 6, 2019
LICENSE Initial code commit Apr 9, 2019
Makefile Simplify dockerfiles (#131) Nov 6, 2019 Update README (#129) Nov 3, 2019
benchmark Initial benchmark diff to catch perf regressions May 18, 2019
comby Initial code commit Apr 9, 2019
comby-server Add server with basic post endpoints Apr 12, 2019
comby.opam Add ubuntu binary docker release and update script (#132) Nov 6, 2019
dune add release build with optimized binary Apr 26, 2019 Update opam and dependencies Sep 22, 2019


Apache-2.0 Build Status Coveralls github Downloads Commit Gitter

See the usage documentation.

A short example below shows how comby simplifies matching and rewriting compared to regex approaches like sed.

Need help writing patterns or have other problems? Consider posting in Gitter.

Install (pre-built binaries)

Mac OS X

  • brew install comby

Ubuntu Linux

  • bash <(curl -sL

  • Arch and other Linux: The PCRE library is dynamically linked in the Ubuntu binary. For other distributions, like Arch, a fixup is needed: ln -s /usr/lib/ /usr/lib/ Alternatively, consider building from source.



  • docker pull comby/comby
click to expand an example invocation for the docker image

Running with docker on stdin:

echo '(👋 hi)' | docker run -a stdin -a stdout -i comby/comby '(:[emoji] hi)' 'bye :[emoji]' lisp -stdin

Or try it live.

Isn't a regex approach like sed good enough?

Sometimes, yes. But often, small changes and refactorings are complicated by nested expressions, comments, or strings. Consider the following C-like snippet. Say the challenge is to rewrite the two if conditions to the value 1. Can you write a regular expression that matches the contents of the two if condition expressions, and only those two? Feel free to share your pattern with @rvtond on Twitter.

if (fgets(line, 128, file_pointer) == Null) // 1) if (...) returns 0
      return 0;
if (scanf("%d) %d", &x, &y) == 2) // 2) if (scanf("%d) %d", &x, &y) == 2) returns 0
      return 0; 

To match these with comby, all you need to write is if (:[condition]), and specify one flag that this language is C-like. The replacement is if (1). See the live example.

Build from source

  • Install opam

  • Create a new switch if you don't have OCaml installed:

opam init
opam switch create 4.09.0 4.09.0
  • Install OS dependencies:

    • Linux: sudo apt-get install pkg-config libpcre3-dev

    • Mac: brew install pkg-config pcre

  • Then install the library dependencies:

git clone
cd comby && opam install . --deps-only -y
  • Build and test
make test
  • If you want to install comby on your PATH, run
make install
You can’t perform that action at this time.