{"id":49127543,"url":"https://github.com/rphle/numfu","last_synced_at":"2026-04-21T16:12:10.915Z","repository":{"id":313638842,"uuid":"1028980841","full_name":"rphle/numfu","owner":"rphle","description":"Functional programming language designed for readable \u0026 expressive code, extensibility, and mathematical computing with arbitrary precision arithmetic.","archived":false,"fork":false,"pushed_at":"2025-11-27T07:57:49.000Z","size":1653,"stargazers_count":10,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-30T01:33:42.524Z","etag":null,"topics":["arbitrary-precision","arbitrary-precision-arithmetic","functional-language","functional-programming","language","mpmath","numfu","programming-language","programming-languages","python","python3"],"latest_commit_sha":null,"homepage":"https://rphle.github.io/numfu/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rphle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-30T10:46:40.000Z","updated_at":"2025-11-24T13:03:27.000Z","dependencies_parsed_at":"2025-09-07T14:43:44.186Z","dependency_job_id":"8b3286b2-8e9c-453d-908a-ec8a43a12693","html_url":"https://github.com/rphle/numfu","commit_stats":null,"previous_names":["rphle/numfu"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rphle/numfu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rphle%2Fnumfu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rphle%2Fnumfu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rphle%2Fnumfu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rphle%2Fnumfu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rphle","download_url":"https://codeload.github.com/rphle/numfu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rphle%2Fnumfu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32099323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T11:25:29.218Z","status":"ssl_error","status_checked_at":"2026-04-21T11:25:28.499Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arbitrary-precision","arbitrary-precision-arithmetic","functional-language","functional-programming","language","mpmath","numfu","programming-language","programming-languages","python","python3"],"created_at":"2026-04-21T16:12:10.133Z","updated_at":"2026-04-21T16:12:10.908Z","avatar_url":"https://github.com/rphle.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://raw.githubusercontent.com/rphle/numfu/main/images/banner.png)\n\n![PyPI - Version](https://img.shields.io/pypi/v/numfu-lang)\n![PyPI - License](https://img.shields.io/pypi/l/numfu-lang)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/numfu-lang)\n![PyPI Downloads](https://img.shields.io/pypi/dm/numfu-lang)\n[![Docs](https://img.shields.io/badge/docs-NumFu-brightgreen)](https://rphle.github.io/numfu/)\n![GitHub stars](https://img.shields.io/github/stars/rphle/numfu?style=social)\n\n\n# NumFu Programming Language\n\n**NumFu** is a pure, interpreted, functional programming language designed for readable \u0026 expressive code, extensibility, and ease of learning for beginners.\n\nNumFu's simple syntax and semantics make it well-suited for educational applications, such as courses in functional programming and general programming introductions. At the same time, as its name suggests, NumFu is also ideal for exploring mathematical ideas and sketching algorithms, thanks to its native support for arbitrary-precision arithmetic.\n\n## Features\n\n- **Arbitrary Precision Arithmetic** - Reliable mathematical computing powered by Python's mpmath\n- **First-Class Functions** - Automatic currying, partial application, and function composition\n- **Expressive Syntax** - Infix operators, spread/rest operators, and lots of syntactic sugar\n- **Tail Call Optimization** for efficient recursive algorithms without stack overflow\n- **Interactive Development** - Friendly REPL and helpful error messages\n- **Minimal Complexity** - Only four core types: `Number`, `Boolean`, `List`, and `String`\n- **Python Integration** - Large \u0026 reliable standard library through NumFu's Python runtime\n- **Extensible** - NumFu is written entirely in Python with the goal of being extensible and easy to understand.\n\n## Quick Start\n\n### Installation\n\n#### From PyPI\n```bash\npip install numfu-lang\n```\n\n#### From Source\n```bash\ngit clone https://github.com/rphle/numfu\ncd numfu\nmake install\n```\n\n### Hello NumFu!\n\nCreate `hello.nfu`:\n```numfu\nimport sqrt from \"math\"\n\n// Mathematical computing with arbitrary precision\nlet golden = {depth -\u003e\n  let recur =\n    {d -\u003e if d \u003c= 0 then 1 else 1 + 1 / recur(d - 1)}\n  in recur(depth)\n} in golden(10) // ≈ 1.618\n\n// Function composition \u0026 piping\nlet add1 = {x -\u003e x + 1},\n    double = {x -\u003e x * 2}\nin 5 |\u003e (add1 \u003e\u003e double) // 12\n\n// Partial Application\n{a, b, c -\u003e a+b+c}(_, 5, _)\n// {a,c -\u003e a+5+c}\n\n// Assertions\nsqrt(49) ---\u003e $ == 7\n\n// Built-in testing with assertions\nlet square = {x -\u003e x * x} in\n  square(7) ---\u003e $ == 49  // ✓ passes\n```\n\nRun it:\n```bash\nnumfu hello.nfu\n```\n\n### Interactive REPL\n\n```bash\nnumfu repl\n```\n\n```\nNumFu REPL. Type 'exit' or press Ctrl+D to exit.\n\u003e\u003e\u003e 2 + 3 * 4\n14\n\u003e\u003e\u003e let square = {x -\u003e x * x} in square(7)\n49\n\u003e\u003e\u003e import max from \"math\"\n\u003e\u003e\u003e [1, 2, 3, 4, 5, 6, 7] |\u003e filter(_, {x -\u003e x%2 == 0}) |\u003e max\n6\n```\n\n## 📖 Documentation\n\n- **[Language Guide](https://rphle.github.io/numfu/docs/)** - Complete language tutorial \u0026 reference\n- **[Stdlib Reference](https://rphle.github.io/numfu/docs/reference/stdlib)** - All built-in modules and utilities\n- **[CLI Reference](https://rphle.github.io/numfu/docs/reference/cli)** - Command-line interface guide\n\n\u003e [!NOTE]\n\u003e As a language interpreted in Python, which is itself an interpreted language, NumFu is not especially fast. Therefore, it is not recommended for performance-critical applications or large-scale projects. However, NumFu has not yet been thoroughly optimized so you can expect some performance improvements in the future.\n\n## Language Overview\n\n### Functions with Automatic Partial Application\n\nFunctions are defined using `{a, b, ... -\u003e ...}` syntax. They're automatically partially applied, so if you supply fewer arguments than expected, the function returns a new function that expects the remaining arguments:\n\n```numfu\nlet fibonacci = {n -\u003e\n    if n \u003c= 1 then n\n    else fibonacci(n - 1) + fibonacci(n - 2)\n}\nfibonacci(10)\n```\n\n### Function Syntax Reconstruction\n\nWhen functions (even partially applied ones) are printed or cast to strings, NumFu reconstructs readable syntax!\n\n```numfu\n\u003e\u003e\u003e {a, b, c -\u003e a + b + c}(_, 5)\n{a, c -\u003e a+5+c}  // Functions print as readable syntax!\n```\n\n### Function Composition and Piping\n\n```numfu\nlet add1 = {x -\u003e x + 1},\n    double = {x -\u003e x * 2}\nin 5 |\u003e (add1 \u003e\u003e double); // 12\n\n// List processing\n[5, 12, 3] |\u003e filter(_, _ \u003e 4) |\u003e map(_, _ * 2)\n// [10, 24]\n```\n\n### Spread/Rest Operators\n\nSupport for variable-length arguments and destructuring:\n\n```numfu\nimport length from \"std\"\n\n{...args -\u003e length(args)}(1, 2, 3)    // 3\n\n{first, ...rest -\u003e [first, ...rest]}(1, 2, 3, 4, 5)\n// [1, 2, 3, 4, 5]\n```\n\n### Module System\n\nExport and import functions and values between modules. Supports path imports and directory modules with `index.nfu`:\n\n```numfu\nimport sqrt from \"math\"\nimport * from \"io\"\n\nlet greeting = \"Hello, \" + input(\"What's your name? \")\n\nexport distance = {x1, y1, x2, y2 -\u003e\n    let dx = x2 - x1, dy = y2 - y1 in\n    sqrt(dx^2 + dy^2)\n}\n\nexport greeting\n```\n\n### Arbitrary Precision Arithmetic\n\nAll numbers use Python's `mpmath` for reliable mathematical computing without floating point errors. Precision can be configured via CLI arguments:\n\n```numfu\nimport pi, degrees from \"math\"\n\n0.1 + 0.2 == 0.3 // true\ndegrees(pi / 2) == 90 // true\n```\n\n### Precise Error Messages\n\nErrors always point to the exact line and column with proper preview and clear messages:\n\n```\n[at examples/bubblesort.nfu:11:17]\n[11]           else if workingarr[i] \u003e workingArr[i + ...\n                       ^^^^^^^^^^\nNameError: 'workingarr' is not defined in the current scope\n```\n```\n[at tests/functions.nfu:36:20]\n[36]   let add1 = {x -\u003e x + \"lol\"} in\n                          ^\nTypeError: Invalid argument type for operator '+': argument 2 must be Number, got String\n```\n\n## 🛠️ Development\n\n### Prerequisites\n\n- Python ≥ 3.10\n\n### Setup Development Environment\n\n```bash\ngit clone https://github.com/rphle/numfu\ncd numfu\nmake dev\n```\nThe `make dev` command also installs Pyright and Ruff via Pip. To format code and check types, it is strongly recommended to run both `ruff check --fix` and `pyright` before committing.\n\n## Building NumFu\n\n```\nmake build\n```\n\nNumFu contains built-ins written in NumFu itself (src/numfu/stdlib/builtins.nfu).\n`make build` first installs NumFu without the built-ins, then parses and serializes the file, and finally performs a full editable install. The script also builds NumFu and creates wheels.\n\n### Building Documentation\n\n```bash\ncd docusaurus \u0026\u0026 npm i \u0026\u0026 cd .. # make sure to install dependencies\n\nmake serve  # local preview\nmake docs   # build to 'docs-build'\n```\n\n## Project Structure\n\n```\nnumfu/\n├── src/numfu/\n│   ├── __init__.py         # Package exports\n│   ├── _version.py         # Version \u0026 metadata\n│   ├── classes.py          # Basic dataclasses\n│   ├── parser.py           # Lark-based parser \u0026 AST generator\n│   ├── interpreter.py      # Complete Interpreter\n│   ├── modules.py          # Import/export \u0026 module resolving\n│   ├── ast_types.py        # AST node definitions\n│   ├── builtins.py         # Built-in functions\n│   ├── cli.py              # Command-line interface\n│   ├── repl.py             # Interactive REPL\n│   ├── errors.py           # Error handling \u0026 display\n│   ├── typechecks.py       # Built-in type system\n│   ├── reconstruct.py      # Code reconstruction for printing\n│   ├── grammar/            # Lark grammar files\n│   └── stdlib/             # Standard library modules\n├── docs/                   # Language documentation\n│   ├── guide/              # User guides\n│   └── reference/          # Reference\n├── docusaurus/             # Docusaurus website\n├── tests/                  # Test files\n├── scripts/                # Build and utility scripts\n└── pyproject.toml          # Configuration\n```\n\n## Testing\n\nNumFu is tested with over 300 tests covering core features, edge cases, and real-world examples — including most snippets from the documentation. Tests are grouped by category and include handwritten cases as well as tests generated by LLMs (mostly Claude Sonnet 4).\n\nEvery test is self-validating using assertions and fails with an error if the output isn’t exactly as expected.\n\nTo run all tests from the `tests` folder:\n\n```bash\nmake test\n```\n\n## Contributing\n\nFound a bug or have an idea? [Open an issue](https://github.com/rphle/numfu/issues).\n\nWant to contribute code?\n- Check existing issues and [TODO.md](https://github.com/rphle/numfu/blob/main/TODO.md) for open tasks.\n- Run all tests before committing.\n- Please consider running `ruff check` and `pyright` to format code and check types before committing.\n- Pull requests are welcome!\n\n\n## License\n\nThis project is licensed under Apache License 2.0 - see the [LICENSE](https://github.com/rphle/numfu/blob/main/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frphle%2Fnumfu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frphle%2Fnumfu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frphle%2Fnumfu/lists"}