# \[ANN\] Down 0.0.1

**URL:** <https://discuss.ocaml.org/t/ann-down-0-0-1/4140>\
**Category:** Community\
**Tags:** announce\
**Created:** [July 23, 2019, 8:10pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140 "2019-07-23T20:10:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [July 23, 2019, 8:10pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/1 "2019-07-23T20:10:09Z")

</div>

Hello,

It’s my pleasure to announce the first release of Down:

> Down is an unintrusive user experience upgrade for the ocaml toplevel (REPL).
> 
> Simply load the zero dependency Down library in the `ocaml` toplevel and you get line edition, history, session support and identifier completion and documentation (courtesy of ocp-index).
> 
> Add this to your `~/.ocamlinit`:
> 
> ```
> #use "down.top"
> 
> ```
> 
> Down is distributed under the ISC license.

Down has no library dependency hence it should be easy to get installed and working in more constrained environments. In particular it works with `ocamlnat`.

Down is also toplevel environmentally friendly: it just adds the `Down` module to your scope and installs a `SIGWINCH` signal handler.

The Down manual can be consulted [here](https://erratique.ch/software/down/doc/manual.html) and is available to you locally via `odig doc down`.

Homepage: [Down / Erratique](https://erratique.ch/software/down)  
Installation: `opam install down`

Best,

Daniel

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [July 23, 2019, 8:56pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/2 "2019-07-23T20:56:18Z")

</div>

Hi Daniel,

Sounds great!

Does Down work on Windows?

Best wishes,  
Nicolás

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [July 23, 2019, 9:15pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/3 "2019-07-23T21:15:37Z")

</div>

> [@nojb](#):
>
> Does Down work on Windows?

I have no idea, that’s for Windows users to tell me. I suspect it should work in `cygwin`, but for the rest I don’t know and I suspect it does not. I never found reliable information on how things are supposed to work for terminals on Windows and I’m still puzzled about the dozens of OCaml ports for Windows.

In any case if anyone’s knows what making a native Window port means and is interested in doing so, the system dependencies are entirely contained [here](https://github.com/dbuenzli/down/blob/master/src/down_stubs.c) (one function for setting the terminal in raw mode, one function to read stdin byte-by-byte and one function to get the `SIGWINCH` signal number).

The rest is pure OCaml and ANSI terminal stuff.

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [July 23, 2019, 9:29pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/4 "2019-07-23T21:29:56Z")

</div>

Thanks, I will look into it.

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [July 23, 2019, 9:35pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/5 "2019-07-23T21:35:14Z")

</div>

Great ! Get in touch if you hit any problem. Also I suspect there will be glitches related to CRLF management, cf. comment [here](https://github.com/dbuenzli/down/blob/75cbc87738376f95cbde223a9abedda1c7904b0a/src/down_std.ml#L110-L118).

---

<div class="post-metadata">

**Author:** ![smolkaj](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/smolkaj/32/266_2.png) [@smolkaj](https://discuss.ocaml.org/u/smolkaj)\
**Post date:** [July 24, 2019, 4:06am UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/6 "2019-07-24T04:06:09Z")

</div>

This is awesome! I love it.

---

<div class="post-metadata">

**Author:** ![ivg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ivg/32/103_2.png) [@ivg](https://discuss.ocaml.org/u/ivg)\
**Post date:** [July 26, 2019, 3:07pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/7 "2019-07-26T15:07:03Z")

</div>

Impressive. As always 🙂 A couple of questions though:

1. Are there any plans to support Merlin or otherwise provide an open-aware completion?
2. What about emacs support?

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [July 26, 2019, 4:48pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/8 "2019-07-26T16:48:36Z")

</div>

> [@ivg](#):
>
> Impressive.

I think it’s rather unimpressive in fact :–) I didn’t think implementing a readline was that easy. Spoiler: linenoise was mentioned a few weeks ago on the `caml-list`, I just printed its source and read it during my idle time to find out there was little magic in all that. This lead me to revive a project about toplevel readline patching I had started a few years ago.

> [@ivg](#):
>
> Are there any plans to support Merlin or otherwise provide an open-aware completion?

There are a few hints [here](https://github.com/dbuenzli/down/issues/11). I’d be keen to work with merlin authors on this — the work can actually be done pretty independently of `Down` I think — but I bet they are already pretty busy. It would also be nice to have people working on the `ocaml` upstream issues (which would benefit other projects like `ocamlfind`, `utop` and `omod`).

> [@ivg](#):
>
> What about emacs support?

Good question I personally stopped using repls and shells from `emacs`, but my interest was revived by this [question](https://github.com/dbuenzli/down/issues/15). I’m a bit unsure what it means in practice though. I kind of timed out on `Down` for now and don’t have too much time invest in it. If you know what your question entails exactly feel free to add more details about what should be done there — this might improve the chances I go about it (making PRs are another option of course but make sure to discuss things with me before).

---

<div class="post-metadata">

**Author:** ![ivg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ivg/32/103_2.png) [@ivg](https://discuss.ocaml.org/u/ivg)\
**Post date:** [July 26, 2019, 5:06pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/9 "2019-07-26T17:06:57Z")

</div>

> [@dbuenzli](#):
>
> Good question I personally stopped using repls and shells from `emacs` , but my interest was revived by this [question](https://github.com/dbuenzli/down/issues/15). I’m a bit unsure what it means in practice though. I kind of timed out on `Down` for now and don’t have too much time invest in it. If you know what your question entails exactly feel free to add more details about what should be done there — this might improve the chances I go about it (making PRs are another option of course but make sure to discuss things with me before).

I was thinking on more in depth integration with the comint-mode (the mode on which the ocaml mode is based). It has some ansi capabilities (enabled with the `ansi-color-for-comint-mode-on`). So I was able to get colorful message from down (after I have enabled ansi):

```ocaml
# Unix.putenv "TERM" "clever";;
- : unit = ()
# #use "down.top";;
Warning: Down v0.0.1 disabled. Failed to set stdin in raw mode.
# 

```

where `Warning` was printed in color (probably maroon).

But here we hit the real problem, is that `down.top` needs the raw input, which you can’t get from Emacs. Of course, implementing full integration will require a lot of work (and elisp coding), but down can at least coexist with emacs, e.g., all the outputs will work fine, as well as session management (which probably is not terminal dependent).

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [July 26, 2019, 5:26pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/10 "2019-07-26T17:26:58Z")

</div>

> [@ivg](#):
>
> as well as session management (which probably is not terminal dependent).

Indeed you should be able to use this in your session above. When `Down` is disabled it just means that `ocaml`’s readline patching did not occur, your are back to `ocaml`, the rest of the Down API remains available though.

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [July 26, 2019, 5:35pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/11 "2019-07-26T17:35:53Z")

</div>

Another thing to mention is that there’s absolutely no magic in sessions these are simply plain `.ml` files stored at a [particular location](https://erratique.ch/software/down/doc/manual.html#data) and made available to you via a short name. So for example `utop` (which does seem to have emacs integration) could certainly easily support them aswell.

---

<div class="post-metadata">

**Author:** ![ivg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ivg/32/103_2.png) [@ivg](https://discuss.ocaml.org/u/ivg)\
**Post date:** [July 26, 2019, 5:42pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/12 "2019-07-26T17:42:21Z")

</div>

> [@dbuenzli](#):
>
> Indeed you should be able to use this in your session above. When `Down` is disabled it just means that `ocaml` 's readline patching did not occur, your are back to `ocaml` , the rest of the Down API remains available though.

Oh, that’s cool, probably the message should be changed a little bit. Because, I was totally under impression that it is totally disabled.

However, my first attempt to use sessions in Emacs has failed (probably you still need to be able to read from the terminal, idk). But I believe it is already out of the scope of discuss, so I will create an [issue](https://github.com/dbuenzli/down/issues/17)

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [August 15, 2019, 1:00pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/13 "2019-08-15T13:00:39Z")

</div>

v0.0.2 has just been published which has a few small adjustements. See the [release notes](https://github.com/dbuenzli/down/blob/master/CHANGES.md#v002-2019-08-15-zagreb).

---

<div class="post-metadata">

**Author:** ![jeremiedimino](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jeremiedimino/32/699_2.png) [@jeremiedimino](https://discuss.ocaml.org/u/jeremiedimino)\
**Post date:** [August 19, 2019, 4:00pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/14 "2019-08-19T16:00:51Z")

</div>

Thanks for this project @dbuenzli, I tried it and it feels fresh and modern. On the Dune side, we are planning to generalise `dune utop` so that it can benefit `down` users as well. It will work by loading a file in the toplevel via `#use` rather than calling a dune command.

---

<div class="post-metadata">

**Author:** ![jeremiedimino](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jeremiedimino/32/699_2.png) [@jeremiedimino](https://discuss.ocaml.org/u/jeremiedimino)\
**Post date:** [April 15, 2020, 4:42pm UTC](https://discuss.ocaml.org/t/ann-down-0-0-1/4140/15 "2020-04-15T16:42:14Z")

</div>

This is supported since Dune 2.5.0. You can now do `#use_output "dune top"` in any toplevel. More info [here](https://github.com/ocaml/dune/blob/91822b26a1cc70cdbc66052814e47e4cede4da06/doc/toplevel-integration.rst).
