A statically typed functional programming language.
git clone https://github.com/malgo-lang/malgo
cd malgo
cabal install
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
To evaluate programs:
malgo eval [OPTIONS] SOURCE
eval
— Evaluate a Malgo program.SOURCE
— Path to the source file to evaluate (required).
--no-opt
— Disable optimizations during compilation.--lambdalift
— Enable lambda lifting.--debug-mode
— Enable debug mode for verbose output.
malgo eval --no-opt --debug-mode examples/malgo/Hello.mlg
This will evaluate examples/malgo/Hello.mlg
with optimizations disabled and debug mode enabled.
The examples/malgo/
directory contains a variety of example programs demonstrating Malgo's features. Here are some highlights:
File: examples/malgo/Hello.mlg
module {..} = import "../../runtime/malgo/Builtin.mlg"
module {..} = import "../../runtime/malgo/Prelude.mlg"
def main = {
putStrLn "Hello, world!"
}
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
}
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
}
https://github.com/malgo-lang/minilisp
This project uses mise for managing development tools and tasks. The mise.toml
file defines tool versions and common development workflows.
- GHC (via ghcup)
- cabal-install
- hpack
- Haskell Language Server (HLS)
- go (for changelog generation)
- watchexec (for file watching)
- git-chglog (for changelog generation)
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 usinggit-chglog
.
See mise.toml
for more details and customization.