{"id":41589765,"url":"https://github.com/biuld/calculator","last_synced_at":"2026-01-24T09:12:19.498Z","repository":{"id":114669972,"uuid":"322812539","full_name":"biuld/calculator","owner":"biuld","description":"an arithmetic calculator written with compiling theory in mind","archived":false,"fork":false,"pushed_at":"2025-06-21T17:02:53.000Z","size":2687,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-21T17:41:43.131Z","etag":null,"topics":["arithmetic-calculator","basic-compiler","compiling-theory","complier-tutorial","functional-programming","haskell"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/biuld.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","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}},"created_at":"2020-12-19T09:36:37.000Z","updated_at":"2025-06-21T17:02:57.000Z","dependencies_parsed_at":"2025-06-08T23:24:40.302Z","dependency_job_id":"5ea37ede-0546-4b0e-8cda-5af20c802721","html_url":"https://github.com/biuld/calculator","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/biuld/calculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biuld%2Fcalculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biuld%2Fcalculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biuld%2Fcalculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biuld%2Fcalculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biuld","download_url":"https://codeload.github.com/biuld/calculator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biuld%2Fcalculator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28722332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T08:27:05.734Z","status":"ssl_error","status_checked_at":"2026-01-24T08:27:01.197Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["arithmetic-calculator","basic-compiler","compiling-theory","complier-tutorial","functional-programming","haskell"],"created_at":"2026-01-24T09:12:19.379Z","updated_at":"2026-01-24T09:12:19.486Z","avatar_url":"https://github.com/biuld.png","language":"Haskell","readme":"# calculator\n\nA statically typed calculator language written in Haskell with a focus on type safety, parsing, and compilation theory.\n\n## Features\n\n- **Rich Type System**\n  - Integers and floating-point numbers\n  - Boolean values\n  - Strings\n  - Tuples\n  - Unit type\n  - First-class functions\n\n- **Expressions and Operations**\n  - Arithmetic operations `(+ - * /)` for `Int` and `Double`\n  - Comparison operations `(== !=)`\n  - Logical operations `(\u0026\u0026 || !)`\n  - Parenthesised expressions\n\n- **Control Flow**\n  - `if … then … else …` expressions\n  - `while` loops\n  - Code blocks `{ e1; e2; … }`\n  - Expression sequences\n\n- **Variables and Functions**\n  - `let` bindings (single and multiple)\n  - Lambda expressions with explicit type annotations\n  - Partial application \u0026 multi-argument functions\n\n## Getting Started\n\n### Prerequisites\n\nThe easiest way to build the project is with [Stack](https://docs.haskellstack.org/). Any recent GHC (≥ 9.8) should work if you prefer Cabal.\n\n### Build\n\n```bash\n# Clone and enter the repository\n$ git clone https://github.com/biuld/calculator.git\n$ cd calculator\n\n# Build everything\n$ stack build\n```\n\n### CLI Usage\n\nThe executable is exposed as `calculator-exe`. Use `stack run` (or Cabal's `cabal run`) to invoke it:\n\n```bash\n# General form\nstack run calculator-exe -- \u003ccommand\u003e [-r] \u003cexpression\u003e\n```\n\n*Commands*\n\n- `parse`   – Parse the expression and pretty-print the Concrete Syntax Tree (CST)\n- `desugar` – Parse and desugar the CST into the typed Abstract Syntax Tree (AST)\n- `eval`    – Evaluate the expression with the small-step interpreter\n\nAdd the `-r` switch to display the raw `Show` instance instead of the pretty printer.\n\n#### Examples\n\n```bash\n# Pretty print CST\nstack run calculator-exe -- parse \"(1 + 2) * 3\"\n\n# Show raw CST\nstack run calculator-exe -- parse -r \"(1 + 2) * 3\"\n\n# Desugar to AST\nstack run calculator-exe -- desugar \"let { f = \\a:Int -\u003e \\b:Int -\u003e a + b; x = 1; y = 2 } in f (x , y)\"\n\n# Evaluate an expression\nstack run calculator-exe -- eval \"let {x = 10; y = 20} in x + y\"\n```\n\n## Project Layout\n\n```\nsrc/\n  Language/Calculator/\n    CST/         -- Lexer, parser, tokens \u0026 CST pretty printer\n    AST/         -- Typed AST, interpreter, value \u0026 environment utilities\n    Desugar.hs   -- CST → AST desugaring with type checking\napp/Main.hs      -- Command-line interface\n\ntest/            -- HSpec test-suite\n```\n\n## Running the Test-suite\n\n```bash\nstack test\n```\n\nThe suite exercises both the parser and desugaring phases (see `test/ParserSpec.hs` and `test/DesugarSpec.hs`).\n\n## Roadmap\n\nPlanned improvements include:\n\n- Pattern matching\n- Algebraic data types\n- A proper optimiser\n- Bytecode compilation and a VM back-end\n\n## License\n\nThis project is licensed under the BSD-3-Clause license. See `LICENSE` for the full text.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiuld%2Fcalculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiuld%2Fcalculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiuld%2Fcalculator/lists"}