morloc-project/morloc
{ "createdAt": "2016-12-02T03:11:38Z", "defaultBranch": "master", "description": "A typed, polyglot, functional language", "fullName": "morloc-project/morloc", "homepage": "", "language": "Haskell", "name": "morloc", "pushedAt": "2025-11-24T01:48:50Z", "stargazersCount": 205, "topics": [ "code-generation", "functional-language", "interoperability", "language", "ontologies", "polyglot", "programming-language", "type-system" ], "updatedAt": "2025-11-12T06:15:35Z", "url": "https://github.com/morloc-project/morloc"}Manual | Discord | Paper Draft | 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.
-
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 more fast, 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 (sumOfSums)
import types
source Py from "foo.py" ("pmap")pmap a b :: (a -> b) -> [a] -> [b]
source Cpp from "foo.hpp" ("sum")sum :: [Int] -> Int
--' Sum a list of lists of numberssumOfSums = sum . pmap sumThe imported code is 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 ints that returns an int:
// C++ code, in "foo.hpp"
#pragma once
#include <vector>#include <numeric>
int sum(std::vector<int> xs) { return std::accumulate( xs.begin(), xs.end(), 0);}Below is Python code that defines a parallel map function:
# Python code, in "foo.py"
import multiprocessing as mp
# Parallel map functiondef pmap(f, xs): with mp.Pool() as pool: results = pool.map(f, xs) return resultsThis program can be compiled and run as below:
$ menv morloc make main.loc
$ menv ./nexus -hUsage: ./nexus [OPTION]... COMMAND [ARG]...
Nexus Options: -h, --help Print this help message -o, --output-file Print to this file instead of STDOUT -f, --output-format Output format [json|mpk|voidstar]
Exported Commands: sumOfSums Sum a list of lists of numbers param 1: [[Int]] return: Int
$ menv ./nexus sumOfSums [[1,2,3],[4]]10