Moggi

A statically typed, purely functional, strictly evaluated language that compiles to PHP, the JVM and .NET.


The language

Algebraic data types, GADTs, pattern matching, type classes and explicit-effect IO. One source compiles to a PHP .phar, a JVM .jar, a .NET .dll, or a native executable — the compiler is written in PHP, and every release ships the runtimes it needs.

data Shape = Circle Double | Rect Double Double
  deriving (Show, Eq)

area :: Shape -> Double
area s = case s of
  Circle r -> 3.141592653589793 * r * r
  Rect w h -> w * h

main :: IO ()
main = do
  putStrLn (show (area (Circle 1.0)))
  putStrLn (show (map area [Rect 2.0 3.0, Circle 1.0]))
3.141592653589793
[6.0, 12.566370614359172]

Getting it

Pick your platform and the distribution you want. Unpack the archive and run it: there is nothing to install, configure or build.

Download moggi-0.1.0-alpha-linux-x86_64.tar.gz

$ curl -LO https://github.com/moggi-lang/moggi/releases/download/0.1.0-alpha/moggi-0.1.0-alpha-linux-x86_64.tar.gz
$ tar -xzf moggi-0.1.0-alpha-linux-x86_64.tar.gz
$ cd moggi && ./bin/moggi version

The picker above needs JavaScript; every archive is listed below either way. Check the download against SHA256SUMS (sha256sum -c SHA256SUMS; shasum -a 256 on macOS) — the archives are not code-signed yet, and quickstart covers what macOS and Windows say about that on first run.

Distributions

They are the same compiler; only runtime/ differs. A bundled runtime is used in preference to the one on your PATH, and whatever a variant does not bundle has to be installed yourself.

DistributionBundles
moggiPHP, .NET SDK, JDK, GraalVM — everything, including --native
moggi-phpPHP — the PHP backend
moggi-dotnetPHP and the .NET SDK
moggi-jvmPHP, JDK and GraalVM
moggi-minimalnothing — uses the php, javac/java and dotnet on your PATH

Every archive

All 25 archives

Windows archives are .zip; the rest are .tar.gz.

DistributionPlatformArchive
moggiLinux (x86_64)moggi-0.1.0-alpha-linux-x86_64.tar.gz
moggiLinux (aarch64)moggi-0.1.0-alpha-linux-aarch64.tar.gz
moggimacOS (Intel)moggi-0.1.0-alpha-macos-x86_64.tar.gz
moggimacOS (Apple silicon)moggi-0.1.0-alpha-macos-aarch64.tar.gz
moggiWindows (x86_64)moggi-0.1.0-alpha-windows-x86_64.zip
moggi-phpLinux (x86_64)moggi-php-0.1.0-alpha-linux-x86_64.tar.gz
moggi-phpLinux (aarch64)moggi-php-0.1.0-alpha-linux-aarch64.tar.gz
moggi-phpmacOS (Intel)moggi-php-0.1.0-alpha-macos-x86_64.tar.gz
moggi-phpmacOS (Apple silicon)moggi-php-0.1.0-alpha-macos-aarch64.tar.gz
moggi-phpWindows (x86_64)moggi-php-0.1.0-alpha-windows-x86_64.zip
moggi-dotnetLinux (x86_64)moggi-dotnet-0.1.0-alpha-linux-x86_64.tar.gz
moggi-dotnetLinux (aarch64)moggi-dotnet-0.1.0-alpha-linux-aarch64.tar.gz
moggi-dotnetmacOS (Intel)moggi-dotnet-0.1.0-alpha-macos-x86_64.tar.gz
moggi-dotnetmacOS (Apple silicon)moggi-dotnet-0.1.0-alpha-macos-aarch64.tar.gz
moggi-dotnetWindows (x86_64)moggi-dotnet-0.1.0-alpha-windows-x86_64.zip
moggi-jvmLinux (x86_64)moggi-jvm-0.1.0-alpha-linux-x86_64.tar.gz
moggi-jvmLinux (aarch64)moggi-jvm-0.1.0-alpha-linux-aarch64.tar.gz
moggi-jvmmacOS (Intel)moggi-jvm-0.1.0-alpha-macos-x86_64.tar.gz
moggi-jvmmacOS (Apple silicon)moggi-jvm-0.1.0-alpha-macos-aarch64.tar.gz
moggi-jvmWindows (x86_64)moggi-jvm-0.1.0-alpha-windows-x86_64.zip
moggi-minimalLinux (x86_64)moggi-minimal-0.1.0-alpha-linux-x86_64.tar.gz
moggi-minimalLinux (aarch64)moggi-minimal-0.1.0-alpha-linux-aarch64.tar.gz
moggi-minimalmacOS (Intel)moggi-minimal-0.1.0-alpha-macos-x86_64.tar.gz
moggi-minimalmacOS (Apple silicon)moggi-minimal-0.1.0-alpha-macos-aarch64.tar.gz
moggi-minimalWindows (x86_64)moggi-minimal-0.1.0-alpha-windows-x86_64.zip

Windows on ARM64 gets no distributions: php.net publishes no Windows ARM64 PHP, so there is nothing to bundle and nothing for moggi-minimal to fall back to. The x86_64 archives run under emulation there. Everything else about the release — the checksums, the provenance attestation, how each runtime is pinned — is in dist/README.md.

Where to go next

Documentation
The language, the compiler pipeline, the LSP.
Standard library
API docs for the bundled base package: the pages that release published, served by the registry.
Packages
The registry: every published package, its versions, and its signatures.
Source
Issues, pull requests, and the CI that builds every runtime.
Releases
Compiler archives, per-platform runtime builds, and checksums.

Status

Early, and honest about it: the compiler is complete enough to be self-hosting-adjacent (it compiles its own standard library and packages a distribution), the package registry is being specified, and the language is changing.


moggi-lang/moggi — GPL-3.0