/l-lang

A very minimal functional programming language implementation

Primary LanguageTypeScriptBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

L Language

L is a very simple untyped functional programming language based on lambda calculus for evaluating simple math expressions.

This project puts a web interface to the interpreter.

Screenshot 2025-05-28 at 15 22 22

🚀 Project Setup & Run Guide

This project contains:

  • ✅ A Haskell Scotty server (l-lang)
  • ✅ A Vite + React client (web-client)
  • ✅ Docker + Docker Compose configuration to run both together
  • Standalone mode for deploying without the Haskell server

📦 Project Structure

./            → Haskell Scotty app (with Dockerfile)
/web-client        → Vite + React app (with Dockerfile)
docker-compose.yml → top-level orchestration

🔧 Prerequisites

For standalone mode:


🏗 How to Build & Run

Option 1: Full Stack with Docker (Recommended for Development)

1️⃣ Clone the repository:

git clone https://github.com/claeusdev/l-lang
cd l-lang

2️⃣ Build and start everything:

docker compose up --build

✅ This will:

Option 2: Standalone React App (No Haskell Server Required)

🚀 Perfect for production deployments or when you just want to try the L language!

1️⃣ Navigate to the web client:

cd web-client

2️⃣ Install dependencies:

npm install

3️⃣ Build the standalone version:

# Using the build script (recommended)
./build-standalone.sh

# Or manually
npm run build:standalone

4️⃣ Serve the standalone app:

# Using the built-in server
npm run serve:standalone

# Or using the executable script directly
./standalone-server.js

# Or serve with any static file server
npx serve dist

Standalone Features:

  • 🔄 Offline L language interpreter - No backend required!
  • 📝 Sample code snippets with valid L language syntax
  • 💾 Local storage for saving your code snippets
  • 🎨 Full UI functionality including Monaco editor
  • 📱 Responsive design works on mobile and desktop

Access the standalone app: http://localhost:8080


🌐 Access the Apps

Service Local URL Description
Full Stack Client http://localhost:5173 React app with Haskell backend
Haskell Server http://localhost:3000 API server (development)
Standalone App http://localhost:8080 Self-contained React app

📚 L Language Examples

The standalone app comes with built-in sample snippets demonstrating L language syntax:

Basic Arithmetic

x = 10
y = 20
x + y
x * y

Lambda Functions

double = \x -> x * 2
triple = \x -> x * 3
square = \x -> x * x

double 5
triple 4
square 6

Function Composition

double = \x -> x * 2
triple = \x -> x * 3
compose = \f -> \g -> \x -> f (g x)

doubleTriple = compose double triple
doubleTriple 5

Let Expressions

double = \x -> x * 2
let x = 10 in double x
let y = 5 in let z = y + 3 in z * 2

Complex Example from test.l

double = \x -> x * 2
triple = \x -> x * x * x
compose = \f -> \g -> \x -> f (g x)

composedDoubleTriple = compose double
trippledDoubledComposed = composedDoubleTriple triple

trippledDoubledComposed 5

let x = 100 in trippledDoubledComposed (double 10)

🔄 Common Commands

Full Stack Development

  • Stop the services:

    docker-compose down
  • Rebuild only:

    docker-compose build
  • View logs:

    docker-compose logs -f
  • Restart with rebuild:

    docker-compose up --build

Standalone Development

  • Development mode:

    cd web-client
    npm run dev
  • Build for production:

    cd web-client
    npm run build:standalone
  • Serve built app:

    cd web-client
    npm run serve:standalone

🚢 Deployment Options

Traditional Static Hosting

The standalone build creates a dist folder that can be deployed to any static hosting service:

  • Netlify
  • Vercel
  • GitHub Pages
  • AWS S3 + CloudFront
  • Any web server (Apache, Nginx)

Self-Hosted

Use the included standalone-server.js script on any Node.js server:

# On your server
cd web-client
npm install --production
npm run build:standalone
node standalone-server.js

Docker Standalone

Build a lightweight Docker image for the standalone app:

FROM node:18-alpine
WORKDIR /app
COPY web-client/package*.json ./
RUN npm install --production
COPY web-client/dist ./dist
COPY web-client/standalone-server.js ./
EXPOSE 8080
CMD ["node", "standalone-server.js"]