Having personally experienced the difficulty of using a programming language without any package managers, we decided to build one called Merchant, for the Mercury logic programming system. Currently, code sharing in the Mercury community means sending tarballs back and forth on the official mailing list. But, this code is not searchable, reproducible, or easily installable. We’re convinced that Merchant will allow for better cooperation between Mercury developers and researchers, thereby, increasing their productivity.

Package managers allow for easy and reproducible installations of libraries by automating the process of downloading, installing, and building code dependencies. In other words, this process is "compiler stage zero". To accomplish this, the package manager needed to be able to parse and comprehend a user facing package description file, download and install package dependencies, and finally integrate with the compiler to build the final executable.

The first challenge we faced was familiarizing ourselves with the Mercury programming environment. Not only were we working in a new language, but we were also taking on an entirely new paradigm, logic programming. From extensive study, we discovered that unlike imperative programming languages where the user directs the computer to find the solution, logic programming relies on establishing constraints to find the desired answer. It was a big shock for us to find that the language didn't even have loops!

Initially, we started by implementing the package description file parser. We, then, adapted an existing json parsing library to extract the desired information from the manifest file. This manifest file is a user editable file containing metadata on the package, including its name, author, and dependencies. Even though we were able to leverage a library, interacting with Mercury code was difficult. Unlike most languages , Mercury has this concept called argument modes, where you can feed inputs or outputs to functions, and get the other back. This breaks the customary model of sequential execution that most other languages follow.

While coding the build system, we also had to work around many idiosyncrasies within the unix environment. After a crash course in bash scripting, linking, and compilation options, we finally had a working prototype.

Finally, we would like to extend a special thanks to the Mercury team for their support!

Built With

Share this project:
×

Updates