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 of base
, which ships with the UCM executable, contains a new set of utilities for working with the Pattern
API and Char
type called Class
. Class
is a new type that represents a set of characters, for example, whitespace
or Class.alphanumeric
. Notably, the character classes, much like regular sets, can be combined with one another with functions like Class.and
and Class.or
.
This new type interfaces nicely with the existing Pattern
API 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 a Char
, and then use it in a Pattern
. Here's what that looks like:
lowerOrSpace = Class.or whitespace Class.lower
Pattern.run
(Pattern.capture (Pattern.many (patterns.char lowerOrSpace)))
"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 for updating 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 Penner in 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 like edit
or display
will accept multiple arguments, the delete
command 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!