Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

morloc-project/morloc

A typed, polyglot, functional language

morloc-project/morloc.json
{
"createdAt": "2016-12-02T03:11:38Z",
"defaultBranch": "master",
"description": "A typed, polyglot, functional language",
"fullName": "morloc-project/morloc",
"homepage": "",
"language": "Haskell",
"name": "morloc",
"pushedAt": "2026-01-06T12:23:42Z",
"stargazersCount": 210,
"topics": [
"code-generation",
"functional-language",
"interoperability",
"language",
"ontologies",
"polyglot",
"programming-language",
"type-system"
],
"updatedAt": "2026-01-06T06:55:58Z",
"url": "https://github.com/morloc-project/morloc"
}

build status github release license: Apache 2.0

Manual | Discord | Paper | X | BlueSky | Email

Morloc

compose functions across languages under a common type system

Why use Morloc?

  • Universal function composition: Import functions from multiple languages and compose them together under a unified, strongly-typed functional framework.

  • Polyglot without boilerplate: Use the best language for each task with no manual bindings or interop code.

  • Type-directed CLI generation: Write concrete function signatures once and automatically generate elegant command-line interfaces with argument parsing, validation, help text, and documentation.

  • Composable CLI tools: Morloc CLI programs can be composed by simply importing them into a new Morloc module and re-exporting their functions.

  • Seamless benchmarking and testing: Swap implementations and run the same benchmarks/tests across languages with consistent type signatures and data representation.

  • Design universal libraries: Build abstract, type-driven libraries and populate them with foreign language implementations, enabling rigorous code organization and reuse.

  • Smarter workflows: Replace brittle application/file-based pipelines with faster, more maintainable pipelines made from functions acting on structured data.

Below is a simple example, for installation details and more examples, see the Manual.

A Morloc module can import functions from foreign languages, assign them general types, and compose new functions:

-- Morloc code, in "main.loc"
module m (vsum)
import root-py
import root-cpp
source Py from "foo.py" ("pmap")
pmap a b :: (a -> b) -> [a] -> [b]
source Cpp from "foo.hpp" ("sum")
sum :: [Real] -> Real
--' Input numeric vectors that will be summed in parallel
--' metavar: VECTORS
type Vectors = [[Real]]
--' Sum a list of numeric vectors
--' return: Final sum of all elements in all vectors
vsum :: Vectors -> Real
vsum = sum . pmap sum

The imported code is natural code with no Morloc-specific dependencies.

Below is the C++ code that defines sum as a function of a standard C++ vector of doubles that returns a double:

// C++ code, in "foo.hpp"
#pragma once
#include <vector>
#include <numeric>
double sum(std::vector<double> xs) {
return std::accumulate(
xs.begin(), xs.end(), 0.0);
}

Below is Python code that defines a parallel map function:

# Python code, in "foo.py"
import multiprocessing as mp
# Parallel map function
def pmap(f, xs):
with mp.Pool() as pool:
results = pool.map(f, xs)
return results

This program can be compiled and run as below:

$ menv morloc make main.loc
$ menv ./nexus vsum -h
Usage: ./nexus vsum VECTORS
Sum a list of numeric vectors
Positional arguments:
VECTORS Input numeric vectors that will be summed in parallel
type: [[Real]]
Return: Real
Final sum of all elements in all vectors
$ menv ./nexus vsum [[1.2],[0,0.1]]
1.3