Roc programming

I finally decided to give Roc a try (Roc is a new-ish programming language from Richard Feldman, who you may know from the Software Unscripted podcast). I found an Emacs mode for it, so it must be time. It was really easy to install.

mkdir roc
cd roc
tar xf ~/Downloads/roc_nightly-linux_x86_64-latest.tar.gz

That includes binaries for both roc and the roc_language_server. I made links to them from a place already in my path.

cd ~/.local/bin
ln -s ~/roc/roc_nightly-linux_x86_64-2025-01-07-a089cf2/roc
ln -s ~/roc/roc_nightly-linux_x86_64-2025-01-07-a089cf2/roc_language_server

And that's that.

❯ roc version
roc nightly pre-release, built from commit a089cf2 on Di 07 Jan 2025 09:02:06 UTC

Let's try the REPL!

❯ roc repl

  The rockin' roc repl
────────────────────────

Enter an expression, or :help, or :q to quit.

» 
» greeting = "Hi"

"Hi" : Str
» audience = "World"

"World" : Str
» "$(greeting) there, $(audience)."

"Hi there, World." : Str
»

For Emacs, after installing the mode (M-x package-install RET roc-ts-mode RET) and the grammar (M-x treesit-install-language-grammar RET), I configured it like so.

(use-package roc-ts-mode
  :ensure t
  :mode ("\\.roc\\'" . roc-ts-mode)
  :hook ((roc-ts-mode . eglot-ensure))
  :config
  (add-to-list 'eglot-server-programs '(roc-ts-mode . ("roc_language_server"))))

Now Emacs is happy with a .roc file.

Roc in Emacs

On to the tutorial!