news
Feb 23, 2023

Unison Codebase Manager version M4h is here

Rebecca Mark

You may have noticed that Unison has been releasing new versions of our tooling with greater frequency. We're churning through the alphabet and have now released M4h.Install and upgrade instructions are located here.

This release is a product of the hard work of many contributors. Thank you all! A few of the release's changes and usage improvements are listed below.

Character classes in the base library

The newest version ofbase,which ships with the UCM executable, contains a new set of utilities for working with thePatternAPI andChartype calledClass.Classis a new type that represents a set of characters, for example,whitespaceorClass.alphanumeric.Notably, the character classes, much like regular sets, can be combined with one another with functions likeClass.andandClass.or.

This new type interfaces nicely with the existingPatternAPI for regex-like text matching and parsing.

For example, if you wanted to match a string that contained either lowercase or whitespace characters, you could first define a class with both of them represented, translate it into aChar,and then use it in aPattern.Here's what that looks like:

lowerOrSpace = Class.or whitespace Class.lower Pattern.run (Pattern.capture (Pattern.many (patterns.char lowerOrSpace))) "hi unison!"
โงจ
Some (["hi unison"], "!")

If you've already installed Unison, but are eager to try out the latest base version with this feature, check out this how-to forupdating your base library.

LSP improvements

We're always looking for improvements to the Unison language for those cases when you've run into an error or need some additional prompting.

The Unison language server will now tell you a specific error if you are matching on something that has the wrong number of arguments for the pattern match.

match eitherValue with
  Left _ -> "left"
  Right one tooMany -> "right"

This code will now produce a friendly error in your editor!

Type information on hover has also been vastly improved for the LSP! Check out the example provided by Chris Pennerin his PR notes here.Thank you Chris! The LSP is a lifesaver! ๐Ÿ™

Better ergonomics when deleting types and terms

Users of the UCM CLI might have noticed that while commands likeeditordisplaywill accept multiple arguments, thedeletecommand only accepted one argument at a time. This could be a bit tedious. ๐Ÿ’€

In M4h, we've added the ability to delete multiple terms and types at once, including a full chain of dependent elements, from leaf to root.

This means if you have a bunch of terms that are related to an implementation that is no longer needed, just remove them all:

.myProject> delete function1 function2 Type3 function4

๐ŸŒป Give the new version a try and let us know what you think!