{"id":21027314,"url":"https://github.com/bynect/constraint-inference","last_synced_at":"2025-06-20T16:12:01.611Z","repository":{"id":107042677,"uuid":"400539804","full_name":"bynect/constraint-inference","owner":"bynect","description":"OCaml implementation of a constraint-based bottom-up type inference algorithm","archived":false,"fork":false,"pushed_at":"2021-12-15T19:57:23.000Z","size":132,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-20T16:11:27.163Z","etag":null,"topics":["constraints","type-checking","type-inference","type-system"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bynect.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}},"created_at":"2021-08-27T14:41:11.000Z","updated_at":"2024-09-25T15:49:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"081d8415-0293-4cca-af1d-b1fdf8ea0071","html_url":"https://github.com/bynect/constraint-inference","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bynect/constraint-inference","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bynect%2Fconstraint-inference","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bynect%2Fconstraint-inference/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bynect%2Fconstraint-inference/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bynect%2Fconstraint-inference/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bynect","download_url":"https://codeload.github.com/bynect/constraint-inference/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bynect%2Fconstraint-inference/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260976921,"owners_count":23091528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["constraints","type-checking","type-inference","type-system"],"created_at":"2024-11-19T11:49:27.259Z","updated_at":"2025-06-20T16:11:56.598Z","avatar_url":"https://github.com/bynect.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Constraint inference\n\nThis repository contains an indipendent implementation of the type\ninference algorithm described in the paper\n[Generalizing Hindley-Milner Type Inference Algorithms](#ref1).\nThe paper [Constraint Based Type Inferencing in Helium](#ref2) describes\nsimilar forms of type constraint.\n\n## Implementation\n\nAll the code contained in this repository is public domain.\n\nThere may be small divergences between this implementation and\nthe paper pseudo-implementation.\n\nThis repo contains the following branches:\n\n- [main](https://github.com/bynect/constraint-inference/tree/main) Original algorithm implementation with some additions, unstable.\n- [original](https://github.com/bynect/constraint-inference/tree/original) Original algorithm implementation with detailed comments.\n- [clean](https://github.com/bynect/constraint-inference/tree/clean) A copy of the original branch without the comments.\n- [parser](https://github.com/bynect/constraint-inference/tree/parser) A copy of the original branch with the addition of a parser and repl.\n- [if-expr](https://github.com/bynect/constraint-inference/tree/if-expr) Same as the parser branch with the addition of n-tuples and if expressions.\n\n## Grammar\n\nThe `main` branch contains a parser and a little repl to check what types is inferred to an expression.\nAdditionally, the `main` branch extends the algorithm described in the paper with n-tuples and if expressions.\nThere is also the addition of a limited form of recursive bindings.\n\n```txt\nE ::=\n  | x\n  | E1 E2\n  | \\x -\u003e E\n  | let x = E1 in E2\n  | rec x = E1 in E2\n  | E1, ..., En\n  | lit\n```\n\n### Example\n\n```txt\nrec fact = \\n -\u003e if eq n 1\n                 then 1\n                 else mul n (fact (sub n 1))\nin fact\n```\n\n```txt\nrec fib = \\n -\u003e if eq n 1\n                then n\n\t\t\t\telse fib (add ((sub n 1)) (fib (sub n 2)))\nin fib\n```\n\n## References\n\n[\u003ca id=\"ref1\"\u003e[1][paper-1]\u003c/a\u003e] Bastiaan Heeren, Jurriaan Hage, and Doaitse Swierstra.\nGeneralizing Hindley-Milner Type Inference Algorithms. Institute of Information and Computing Sciences,\nUtrecht University, Netherlands, 2002.\n\n[\u003ca id=\"ref2\"\u003e[2][paper-2]\u003c/a\u003e] Bastiaan Heeren, Jurriaan Hage, and S. Doaitse Swierstra.\nConstraint Based Type Inferencing in Helium. Institute of Information and Computing Science,\nUniversiteit Utrecht, Netherlands, 2003.\n\n[paper-1]: http://www.cs.uu.nl/research/techreps/repo/CS-2002/2002-031.pdf\n[paper-2]: http://www.open.ou.nl/bhr/heeren-cp03.pdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbynect%2Fconstraint-inference","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbynect%2Fconstraint-inference","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbynect%2Fconstraint-inference/lists"}