Metadata-Version: 2.4
Name: calc-rs-lang
Version: 0.3.3
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: marimo>=0.24.0 ; extra == 'notebook'
Requires-Dist: anywidget>=0.11.0 ; extra == 'notebook'
Requires-Dist: traitlets>=5.16.1 ; extra == 'notebook'
Requires-Dist: maturin>=1.15.0 ; extra == 'notebook'
Provides-Extra: notebook
License-File: LICENSE
Summary: A strongly typed, spreadsheet-style expression engine
Keywords: calculator,expression,spreadsheet,currency,rust
Author: Attica-oss
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/Attica-oss/calc_rs

<p align="center">
  <img src="docs/assets/banner.png" alt="calc — a scripting language for building things simply" width="100%">
</p>

# calc_rs

calc_rs is a strongly typed scripting language for calculations and structured
data. The core is written in Rust, and is available as a CLI, Rust library,
and Python extension module.

## Key features

- **Strongly typed**: Currency, percentages, dates, durations, tonnage, tables,
  and other domain values are distinct types rather than decorated numbers.

- **Calculations**: Designed for real-world calculations with units and
  domain-specific values, while retaining a concise expression-oriented
  syntax.

- **Data & Tables**: Tables are first-class values that can be created,
  transformed, queried, and persisted directly from the language.

- **Pipelines**: Compose transformations with `|>`, making data workflows read
  from top to bottom instead of nesting operations.

- **Schema-aware**: CSV data can be loaded with inferred or explicit schemas.
  Values are checked against their declared types rather than silently
  converted to text.

- **Scripting**: Run individual expressions, `.calc` files, or multi-file
  projects with imports and modules.

- **Interactive**: A REPL with syntax highlighting, completion, signatures,
  multi-line expressions, and session state.

- **Editor Support**: Built-in Language Server support provides diagnostics,
  completion, and hover information.

- **Embeddable**: Use the engine directly from Rust or Python.

- **Rust**: Written in Rust with the performance-critical engine implemented
  natively and exposed through a library API.

## Why calc_rs?

calc_rs is designed for programs where calculations and structured data are
central to the problem.

Instead of treating everything as an untyped number or string, values carry
their meaning and type:

```calc
let price = $12.50
let quantity = 3

price * quantity
// $37.50
```

The same language can work with structured data:

```calc
load("sales.csv")
  |> filter([region] == "EU")
  |> extend("net", [gross] - [tax])
  |> groupby("region", "net", "sum")
  |> sort([sum_net], "desc")
```

Schemas can be declared explicitly when the shape of the data matters:

```calc
struct Shipment {
  date: date,
  port: text,
  box: container,
  amount: currency
}

load("jan.csv", Shipment)
```

This lets the language check data as it enters the program rather than
discovering type problems later.

## Philosophy

The goal of calc_rs is to provide a scripting language that:

- Keeps calculations concise without sacrificing strong typing.
- Treats domain-specific values as real types.
- Makes structured data and tables first-class language values.
- Makes data transformations readable through pipelines.
- Detects schema and type errors before they become silent data corruption.
- Works interactively as well as in scripts and multi-file projects.
- Can be embedded in both Rust and Python applications.
- Provides useful editor tooling without requiring a separate runtime.

calc_rs is written in Rust, giving the engine control over its data
representation and performance-critical execution while keeping the language
small and embeddable.

## Install

### CLI

```sh
uv tool install calc-rust
```

Then:

```sh
calc_rs '$5.00 * 3'
# $15.00
```

Or run without installing:

```sh
uvx --from calc-rust calc_rs '$5.00 * 3'
```

### Desktop app (Windows and macOS)

```sh
uv tool install calc-desktop
calc_desktop path/to/project
```

The app installs like the CLI — `uv` unpacks it into your user folder, so no
installer runs. On Windows it needs the WebView2 runtime (included in Windows
11). On Linux, build it from [`desktop/`](desktop/) instead.

### Python

```sh
pip install calc-rs-lang
```

```python
import calc_rs

calc_rs.evaluate("$5.00 * 3")
# Currency($15.00)
```

### Rust

```toml
[dependencies]
calc_rs = { git = "https://github.com/Attica-oss/calc_rs" }
```

## Documentation

- [Language Reference](docs/USAGE.md)
- [LSP / Editor Support](docs/LSP.md)
- [Examples](examples/)
- [Changelog](CHANGELOG.md)

## Development

```sh
cargo test
maturin develop --release
```

## License

MIT — see [LICENSE](LICENSE).

