{"id":13749194,"url":"https://github.com/lorepozo/polytype-rs","last_synced_at":"2026-04-08T19:31:00.301Z","repository":{"id":45168583,"uuid":"121579117","full_name":"lorepozo/polytype-rs","owner":"lorepozo","description":"A Hindley-Milner polymorphic typing system","archived":false,"fork":false,"pushed_at":"2023-12-18T13:36:02.000Z","size":229,"stargazers_count":60,"open_issues_count":4,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-04-02T06:51:17.478Z","etag":null,"topics":["hindley-milner","polymorphism","type-inference","types"],"latest_commit_sha":null,"homepage":"https://docs.rs/polytype","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lorepozo.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}},"created_at":"2018-02-15T00:59:06.000Z","updated_at":"2025-10-28T21:04:15.000Z","dependencies_parsed_at":"2023-12-18T14:34:52.853Z","dependency_job_id":"cc5a2826-e7bf-4266-8e1b-b3ec1aa6cb1b","html_url":"https://github.com/lorepozo/polytype-rs","commit_stats":null,"previous_names":["lucasem/polytype-rs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lorepozo/polytype-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorepozo%2Fpolytype-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorepozo%2Fpolytype-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorepozo%2Fpolytype-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorepozo%2Fpolytype-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lorepozo","download_url":"https://codeload.github.com/lorepozo/polytype-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorepozo%2Fpolytype-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31571599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"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":["hindley-milner","polymorphism","type-inference","types"],"created_at":"2024-08-03T07:00:56.776Z","updated_at":"2026-04-08T19:31:00.273Z","avatar_url":"https://github.com/lorepozo.png","language":"Rust","funding_links":[],"categories":["Projects"],"sub_categories":["Libraries"],"readme":"# polytype\n\n[![CI](https://github.com/lorepozo/polytype-rs/actions/workflows/ci.yaml/badge.svg)](https://github.com/lorepozo/polytype-rs/actions/workflows/ci.yaml)\n[![crates.io](https://img.shields.io/crates/v/polytype.svg)](https://crates.io/crates/polytype)\n[![docs.rs](https://docs.rs/polytype/badge.svg)](https://docs.rs/polytype)\n\nA [Hindley-Milner](https://wikipedia.org/wiki/Hindley–Milner_type_system) polymorphic typing system.\nImplements type inference via unification.\n\n## Usage\n\n```toml\n[dependencies]\npolytype = \"7.0\"\n```\n\n**`polytype`** provides the\n[`TypeScheme`](https://docs.rs/polytype/~7/polytype/enum.TypeScheme.html) and\n[`Type`](https://docs.rs/polytype/~7/polytype/enum.Type.html) enums, the\n[`Context`](https://docs.rs/polytype/~7/polytype/struct.Context.html)\nstruct, and the\n[`tp!`](https://docs.rs/polytype/~7/polytype/macro.tp.html) and\n[`ptp!`](https://docs.rs/polytype/~7/polytype/macro.ptp.html) macros which\nhelp to concisely create types and type schemes.\n\nUnification:\n\n```rust\nlet mut ctx = Context::default();\n\n// t1: list(int → α) ; t2: list(β → bool)\nlet t1 = tp!(list(tp!(@arrow[tp!(int), tp!(0)])));\nlet t2 = tp!(list(tp!(@arrow[tp!(1), tp!(bool)])));\nctx.unify(\u0026t1, \u0026t2).expect(\"unifies\");\n\nlet t1 = t1.apply(\u0026ctx);\nlet t2 = t2.apply(\u0026ctx);\nassert_eq!(t1, t2); // list(int → bool)\n```\n\nApply a type context:\n\n```rust\nlet mut ctx = Context::default();\n// assign t0 to int\nctx.extend(0, tp!(int));\n\nlet t = tp!(list(tp!(0)));\nassert_eq!(t.to_string(), \"list(t0)\");\nlet t = t.apply(\u0026ctx);\nassert_eq!(t.to_string(), \"list(int)\");\n```\n\nInstantiate a `TypeScheme`:\n\n```rust\nlet mut ctx = Context::default();\n\n// ∀α. list(α)\nlet scheme = ptp!(3; tp!(list(tp!(3))));\n\n// They instantiate to new fresh type variables\nlet t1 = scheme.instantiate(\u0026mut ctx);\nlet t2 = scheme.instantiate(\u0026mut ctx);\nassert_eq!(t1.to_string(), \"list(t0)\");\nassert_eq!(t2.to_string(), \"list(t1)\");\n```\n\nSee the [documentation](https://docs.rs/polytype) for more details.\n\n## Features\nBy default `polytype` includes a type parser that can be invoked with\n[str::parse](https://doc.rust-lang.org/stable/std/primitive.str.html#method.parse).\nThis can be disabled with `default-features = false`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florepozo%2Fpolytype-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Florepozo%2Fpolytype-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florepozo%2Fpolytype-rs/lists"}