morloc

@morloc-project.bsky.social

The project page for morloc, a language where you can compose functions across languages under a common type system

For seven years I have procrastinated writing proper error formatting. There was always something more pressing to do. But now it is finally here. Well, at least the formatting. Still more work needed to make the error analysis more informative.

This image shows a morloc build command on code that has a type error (the addition of a string to a number). The error is described and the source code of the offending line is shown.

Releasing #morloc v0.60.0! This release introduces custom binary operator support. The root libraries have been rewritten to offer standard arithmetic, logical, and comparison binary operators. The composition operator (see image) is now defined in #morloc code, not hard wired.

This image shows the morloc code defining a custom binary operator for composing functions. It is set to be left associative with a precedence of 9.

Here is a template Morloc app. With a few more lines, we can pass in strongly-typed, polyglot Morloc libraries. I'll make a larger demo using an Elm-like architecture soon.

A side-by-side view of Morloc code, left, and Python code, right. The python code defines a small app with uvicorn and fastapi and exports the functions, run_app, that starts the app. The Morloc code imports run_app, defines docstrings specifying how the two arguments (host and port) map to CLI arguments, and rexports it.

The new #morloc getter and setter patterns are the most radical of the new changes in v0.57.1. They offer a succinct syntax for generating functions that access or update data. They replace the many little helper functions #morloc previously required. Here are a few examples:

Bild

*multi-line strings* allow triple-quotes to enclose strings that span multiple lines and automatically trims whitespace. See example below where the trimmed whitespace is highlighted:

An image of code showing a multi-line string and describing the rules used to trim whitespace:

1. If the first character in the string is a newline,
   it will be removed
2. If the final character in the string is a newline,
   it will be removed
3. An equal number of leading whitespace characters is 
   removed from each line such that the line with the
   fewest leading whitespace characters is flush left.

*string interpolation* allows #morloc expressions to be substituted into strings. Currently the behavior is quite minimal and works only for expressions that evaluate to strings. In the future more formatting options will be added.

The expression `hellowWorld x = "Hello #{x}"`, which shows how morloc expressions can be substituted into string expressions.

Releasing Morloc version 0.57.1! There are 5 major new features: placeholder syntax, string interpolation, multi-line strings, and getter and setter patterns. I'll introduce all of each of these in dedicated posts.

🌟 Huge thanks to everyone who joined the first virtual #morloc #hackathon yesterday! We spent the day beta-testing the Morloc language, smoothing out install issues and running our first programs together. 🚀 Morloc execution is now tested on Linux, MacOS, and Windows (via WSL)!