Skip to content

malgo-lang/malgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

malgo

Ask DeepWiki CI

A statically typed functional programming language.

Requirement

Installation

Installing Malgo

git clone https://github.com/malgo-lang/malgo cd malgo cabal install

Directory Structure

A brief overview of the main directories and files:

app/ # CLI entry point (Main.hs) docs/ # Documentation and references examples/ # Example Malgo source files nix/ # Nix-related files runtime/ # Malgo runtime and standard library src/ # Main source code (Haskell) test/ # Test suites and testcases README.md # This file malgo.cabal # Cabal project file 

Usage

To evaluate programs:

malgo eval [OPTIONS] SOURCE
  • eval — Evaluate a Malgo program.
  • SOURCE — Path to the source file to evaluate (required).

Options

  • --no-opt — Disable optimizations during compilation.
  • --lambdalift — Enable lambda lifting.
  • --debug-mode — Enable debug mode for verbose output.

Example

malgo eval --no-opt --debug-mode examples/malgo/Hello.mlg

This will evaluate examples/malgo/Hello.mlg with optimizations disabled and debug mode enabled.

Examples

The examples/malgo/ directory contains a variety of example programs demonstrating Malgo's features. Here are some highlights:

Hello, world

File: examples/malgo/Hello.mlg

module {..} = import "../../runtime/malgo/Builtin.mlg" module {..} = import "../../runtime/malgo/Prelude.mlg" def main = { putStrLn "Hello, world!" } 

Fibonacci number

File: examples/malgo/Fib.mlg

module {..} = import "../../runtime/malgo/Builtin.mlg" module {..} = import "../../runtime/malgo/Prelude.mlg" infix 4 (<=) def (<=) = { x y -> leInt32 x y } infixl 6 (+) def (+) = { x y -> addInt32 x y } infixl 6 (-) def (-) = { x y -> subInt32 x y } def fib = { n -> if (n <= 1) { 1 } { fib (n - 1) + fib (n - 2) } } def main = { fib 5 |> toStringInt32 |> putStrLn } 

List operations

File: examples/malgo/List.mlg

module {..} = import "../../runtime/malgo/Builtin.mlg" module {..} = import "../../runtime/malgo/Prelude.mlg" infix 4 (<=) def (<=) : Int32 -> Int32 -> Bool def (<=) = {x y -> leInt32 x y} infixl 6 (+) def (+) : Int32 -> Int32 -> Int32 def (+) = {x y -> addInt32 x y} infixl 6 (-) def (-) : Int32 -> Int32 -> Int32 def (-) = {x y -> subInt32 x y} def map : (a -> b) -> List a -> List b def map = { _ Nil -> Nil, f (Cons x xs) -> Cons (f x) (map f xs) } def sum : List Int32 -> Int32 def sum = { Nil -> 0, Cons x xs -> x + sum xs } -- [0 .. n] def below : Int32 -> List Int32 def below = { n -> if (n <= 0) { [0] } { Cons n (below (n - 1)) } } def main = { sum (map (addInt32 1) (below 10)) |> toStringInt32 |> putStrLn } 

Lisp interpreter

https://github.com/malgo-lang/minilisp

For Developers

This project uses mise for managing development tools and tasks. The mise.toml file defines tool versions and common development workflows.

Toolchain

  • GHC (via ghcup)
  • cabal-install
  • hpack
  • Haskell Language Server (HLS)
  • go (for changelog generation)
  • watchexec (for file watching)
  • git-chglog (for changelog generation)

Common Tasks

Run these with mise run <task>:

  • setup — Install and set up all required tools and dependencies.
  • setup-hls — Build and set up Haskell Language Server for the project.
  • build — Build the project (hpack && cabal build).
  • test — Run the test suite. Optionally filter tests with --option match=<pattern>.
  • exec — Run the project executable (cabal exec malgo-exe).
  • changelog — Generate the changelog using git-chglog.

See mise.toml for more details and customization.

Packages

No packages published

Contributors 6

Languages