Unison - local development - how to?

I am trying the Unison track. I always create a Docker container for my development. With Unison I find it a little bit harder, so I would like to ask for help or tips.

I created a Dockerfile, based on Unison docs. That works just fine. I even tunneled port for UCM, so I can run it inside the container, but access on my host.
One strange thing I notice - I cannot access documentation for base.Char.!=. But when I go to share.unison-lang.org, I can see it. Actually I cannot access docs for any (randomly picked) base.Char term. But others work (e.g. Nat).
Any ideas? :)

Second, I am a bit confused on how to test exercises.
I can write foobar.u, it gets loaded in UCM, but if I run test in UCM, I get 500 something passing tests, but it’s base tests.
When I try to load it, I get:

load leap.test.u

  I couldn't find any definitions matching the name leap inside the namespace .
      2 |   Test.label "leap should be false when year is not divisible by 4" (Test.expect ((leap 2015) === false))
  Some common causes of this error include:
    * Your current namespace is too deep to contain the definition in its subtree
    * The definition is part of a library which hasn't been added to this project
  To add a library to this project use the command: `fork <.path.to.lib> .lib.<libname>`
  Whatever it is, its type should conform to Nat -> Boolean.

I am still confused from namespace, and how do I work with different exercises in the track. My file structure:


So if I want to solve hello-world, I go like this:

cd hello-world

Then when I modify hello.u, UCM registers it.
When I want to solve leap after that, I quit UCM, cd to leap, and repeat.
Now leap is autodetected by UCM.

I couldn’t find how to make UCM listen in subdirectories:

# change leap/leap.u
# UCM notices

Any help is appreciated :slight_smile:

Unison is unusual in that it stores the code in it’s own database, and you only use text files to interact with the UCM (for ex: load code into the text file, edit it and then save updated definitions back to the database).

I couldn’t find how to make UCM listen in subdirectories:

You don’t need subdirectories of text files in Unison, you pretty much only use one scratch.u file.

You should watch @rlmark’s video: Unison Exercism track workflow - YouTube
And there are some exercism docs describing a suggested workflow: Testing on the Unison track | Exercism's Docs

Hi there!! Thanks for trying out Unison! By “cannot access documentation” do you mean that the browser command ui does not succeed at opening up your default browser, or that trying for example view base.Char.doc in the UCM console does not work? If it’s the local UI in the browser that fails to load, you may need to expose another port via docker networking. I’ll have to double check which port the ui attempts to connect on.

Unfortunately there’s no way to make the UCM listen for file saves all the way down a particular directory tree. It’s always going to look for .u suffixed files in the directory where it is launched, so cd ing to /leap to look for leap.u and leap.test.u is the right call.

Hi @joohan :wave:

I’m also on the Unison track, and I think I can help here.

You’ve done the difficult part which id getting Docker setup for Unison. I’m developing on my Mac, but since your issues are native to Unison, my solutions may help.

How are you viewing the docs for methods? This is how I view mine

For tests, you’d have to follow this sequence

  • Update the files in the directory you’ve opened ucm in
  • UCM will detect changes to your .u file and ask if you want to add or update the definitions of these functions in its database.
  • Simply type add or update in UCM, depending on if this is a new method or one you’re updating.
  • Now Unison has the definition of the method you want to test
  • Run your tests the same way you have here load some_task.test.u

If you have any further question, please ask

One thing that may be weird with your setup if you have UCM running in some Docker container, I don’t know which folder it’s watching: a folder in the Docker box, or a folder in your computer? It may be that the reason you cannot find definitions of method you write in Unison is that UCM is simply unaware. So maybe check that as well

I read about the DB, but because Unison is pretty unique, sometimes I get confused. Thank you for stating explicitly.

I will look at the links you provided. Thank you :)

@rlmark I’m sorry I didn’t write it clearly.
I can run the ui command. I can access the local web-documentation, just specific terms (like that Char) show an error. Most do work though.
The error is:

Unable to load definition: Term base.Char.!= — please try again.

When I run docs base.Char.!= in UCM CLI, I get it correctly:

.> docs base.Char.!=                                                 

  Returns `true` if the two characters are not equal, and `false` otherwise.
  # Examples
        ?a Char.!= ?a
        ?a Char.!= ?b

In the browser I have port exposed like this:

docker run ... -p 36000:36000 ...

and in the container:

../unisonlanguage/ucm --port 36000

Because most other docs work in the browser, it will be some strange error. I might dig deeper, or just use CLI or share.unison-lang.org.

Hello @igbanam :)

When I view it the way you send, it works. But when I go to:!%3D, I don’t see it. I will try it further. Maybe it’s the URL encoding.

Thank you for your steps to test. I will try them soon.

I use volume linking to host directory. Watching for .u files works, I just thought it would also look into subdirectories. But as @dreig and @rlmark said, Unison doesn’t do that, so I will adapt :slight_smile:

I think this may be a port-forwarding issue then. UCM starts a web server for ui on a specific port. We have to somehow know this port beforehand and port-forward it from the Docker box to a port on your local computer.

I don’t think so. The --port when running ucm opens it on the provided port. And as I said, most help works, just some don’t. Today I got the impression it’s mostly help for terms containing >, !, =,…

But it’s not that big of an issue.

1 Like

Oh, that detail is very interesting. I’m checking on my own local UI and none of the operators with symbol-y names can be rendered. I’ll file a bug! It’s possible we’ve experienced a regression since the last UCM release. Thank you for reporting and identifying this! It’ll help others have a better experience.

1 Like

@rlmark yay! I’m glad I was helpful to identify it.

Also thank you to everyone who replied. I watched the video + read the docs provided here, they seem to provided answers to all my problems.

1 Like