Sign inSign up

dtreskunov/reasonml

By dtreskunov

•Updated over 8 years ago

Providing a sane working environment for coding in OCaml/ReasonML in Emacs

Image
0

963

dtreskunov/reasonml repository overview

⁠ReasonML Docker Image for Development

After getting frustrated by instructions⁠ on setting up ReasonML⁠ on Windows, I decided to build a Docker image that would provide a sane working environment for coding in ReasonML.


⁠Image Contents

The image contains:

  • OCaml⁠ - strongly-typed functional language
  • ReasonML⁠ - syntax sugar for OCaml making it JavaScript-like
  • OPAM⁠ - package manager for OCaml
  • Emacs⁠ - text editor operating system
  • ...and various tools:
    • merlin⁠ - context sensitive completion for OCaml in Vim and Emacs
    • ocp-indent⁠ - indentation tool for OCaml, to be used from editors like Emacs and Vim
    • tuareg⁠ - Emacs OCaml mode
  • ...as well as Emacs plugins:
    • magit⁠ - Git GUI porcelain
    • helm⁠ - incremental completion and selection narrowing framework
    • projectile⁠ - Project Interaction Library for Emacs
    • auto-complete⁠ - 'nuff said
    • company⁠ - Modular in-buffer completion framework for Emacs
    • utop⁠ - universal toplevel (REPL aka shell) for OCaml/ReasonML
    • ...here's a nice demo⁠ of what Helm and Projectile can do

⁠Usage

⁠Emacs in the terminal
docker run --rm -it dtreskunov/reasonml emacs
⁠Work on your project's source code

This will mount the source you have (on the Docker host) as the /project directory in the container. On Windows, <path-to-project> should be of the form /c/users/....

docker run --rm -it -v /<path-to-project>:/src -w /project dtreskunov/reasonml emacs .
⁠Emacs GUI via X Server
  1. Install an X Server. On Windows, you can use Chotolatey⁠ and run choco install -y vcxsrv. Make sure that access controls are disabled. See here⁠ for more details.
  2. Find out the IP address of the Docker host, e.g. 192.168.1.100.
docker run --rm -it --net=host dtreskunov/reasonml emacs -d 192.168.1.100:0

⁠Workflow

This image uses the "alternative" installation method mentioned in ReasonML docs (OPAM). It supports the following workflow for setting up a new project:

  1. Mount an empty host directory inside the container (say, /project) (see below)
  2. Duplicate the layout from /template-project:
    • src/* - put your source files (OCaml or ReasonML) here
    • src/jbuild - instructions for jbuilder (see here⁠)
    • <project-name>.opam - instructions for OPAM (see here⁠ and here⁠)
  3. Run opam pin add <project-name> /project --no-action to tell OPAM that <project-name> is installed locally in this location
  4. Run opam depext --install <project-name> to tell OPAM to install dependencies, compile, and install the project
  5. Make changes to the source code
  6. To recompile:
    • Run opam upgrade <project-name> - installs build artifacts into ~/.opam/4.05.0
    • or run jbuilder build @install - puts artifacts into _build/install/default, which is used by the Merlin Emacs plugin

See here⁠ for an explanation of this workflow.

Tag summary

Content type

Image

Digest

Size

997.9 MB

Last updated

over 8 years ago

docker pull dtreskunov/reasonml