guise-lang/README.org

2.7 KiB
Executable File

Guise

Overview

Guise is a concatenative, functional, statically-typed, stack-based language with S-expression syntax, implemented in Guile.

It combines:

  • Joy's pure concatenative semantics
  • Factor's practical stack language design
  • Scheme's S-expression syntax
  • ML's algebraic data types and static type inference

Key Features

Stack-Based Evaluation

All computation happens through stack manipulation. Operations execute left-to-right, consuming and producing values on the stack.

First-Class Quotations

Code blocks are first-class values that can be passed around and executed with call.

Algebraic Data Types

Define product types (tuples) and sum types (tagged unions) with auto-generated constructors and accessors.

Static Type Inference

Type signatures are checked at compile time, with full type inference for stack effects.

Module System

Organize code with modules, imports, and public/private visibility control.

Quick Start

Running the REPL

GUILE_LOAD_PATH=src GUILE_AUTO_COMPILE=0 guile --language=guise

Note: GUILE_AUTO_COMPILE=0 prevents Guile from trying to compile Scheme runtime modules using the Guise compiler.

Running Examples

GUILE_LOAD_PATH=src GUILE_AUTO_COMPILE=0 guile --language=guise < examples/basic.guise

Your First Guise Program

;; Stack operations - left to right evaluation
(5 3 +)           ; Push 5, push 3, add → 8
(dup *)           ; Duplicate top, multiply → square

;; Define a word (function) with stack effect signature
(define square (number -> number)
  (dup *))

(5 square)        ; → 25

;; Quotations are first-class code blocks
'(dup *)          ; Push quotation onto stack
(5 '(dup *) call) ; Execute quotation → 25

;; Higher-order functions
(define twice ('a (quot ('a -> 'a)) -> 'a)
  (dup call call))

(5 'square twice) ; → 625 (5 squared twice)

Examples

See the examples/ directory:

  • basic.guise - Basic arithmetic and stack operations
  • quotations.guise - Higher-order functions with quotations
  • numbers.guise - Number type hierarchy examples
  • tuples.guise - Tuple construction and operations

Documentation

Language Reference

Contributing

Guise is in active development. Contributions, feedback, and ideas are welcome!

License

Guise is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

See the COPYING file for the full license text, or visit GPL-3.0.