{"id":18009893,"url":"https://github.com/kekyo/typeinferencer","last_synced_at":"2025-03-26T14:31:35.212Z","repository":{"id":45878382,"uuid":"431291824","full_name":"kekyo/TypeInferencer","owner":"kekyo","description":"Minimal type inference Algorithm W and Algorithm M in F#","archived":false,"fork":false,"pushed_at":"2023-10-23T06:57:09.000Z","size":766,"stargazers_count":34,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-30T03:48:44.345Z","etag":null,"topics":["algorithm-m","algorithm-w","ast","fsharp","functional","type-inference"],"latest_commit_sha":null,"homepage":"","language":"F#","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/kekyo.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-11-24T00:02:23.000Z","updated_at":"2024-06-02T07:46:26.000Z","dependencies_parsed_at":"2024-10-30T02:52:24.482Z","dependency_job_id":null,"html_url":"https://github.com/kekyo/TypeInferencer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kekyo%2FTypeInferencer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kekyo%2FTypeInferencer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kekyo%2FTypeInferencer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kekyo%2FTypeInferencer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kekyo","download_url":"https://codeload.github.com/kekyo/TypeInferencer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245670737,"owners_count":20653413,"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":["algorithm-m","algorithm-w","ast","fsharp","functional","type-inference"],"created_at":"2024-10-30T02:11:27.596Z","updated_at":"2025-03-26T14:31:34.753Z","avatar_url":"https://github.com/kekyo.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Algorithm W and Algorithm M in F#\n\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n\n[![NuGet TypeInferencer](https://img.shields.io/nuget/v/TypeInferencer.svg?style=flat)](https://www.nuget.org/packages/TypeInferencer)\n[![CI build (main)](https://github.com/kekyo/TypeInferencer/workflows/.NET/badge.svg?branch=main)](https://github.com/kekyo/TypeInferencer/actions?query=branch%3Amain)\n\n## What is this?\n\nThis is a type inference implementation of both `Algorithm W` and `Algorithm M` written in F#.\n\nReferenced articles:\n\n1. [`Algorithm W Step by Step`](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.65.7733\u0026rep=rep1\u0026type=pdf)\n2. [`Proofs about a Folklore Let-Polymorphic Type\nInference Algorithm`](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.29.4595\u0026rep=rep1\u0026type=pdf)\n\nThe method of article 1 was implemented with care not to change it as much as possible.\n\n### Example\n\n```fsharp\n// NuGet package is available.\n#r \"nuget: TypeInferencer\"\n\nopen TypeInferencer\n\n// `let id = fun x -\u003e x in id id`\nlet expr =\n    ELet(\"id\",\n        EAbs(\"x\", EVar \"x\"),\n        EApp(EVar \"id\", EVar \"id\"))\n\n// Type environment (is empty)\nlet env = TypeEnv []\n\n// Do inferring with `Algorithm W` (top-down)\nlet actual = infer TopDown env expr\n\n// Pretty printing\nprintfn \"Expression: %s\" (show expr)\nprintfn \"Actual: %s\" (show actual)\n```\n\nResults:\n\n```\nExpression: let id = fun x -\u003e x in id id\nActual: a3 -\u003e a3\n```\n\n---\n\n## How to play it\n\nA playing guide is here:\n\n* English:\n  * [Markdown (Inside this repository)](docs/HowToPlay_en.md)\n  * [Rendered pdf (pandoc/wkhtmltopdf)](docs/HowToPlay_en.pdf)\n* Japanese:\n  * [Markdown (Inside this repository)](docs/HowToPlay_ja.md)\n  * [Rendered pdf (pandoc/wkhtmltopdf)](docs/HowToPlay_ja.pdf)\n\n---\n\n## Basic interface\n\n### Well-defined types\n\nAST expression type:\n\n```fsharp\ntype public Lit =\n    | LInt of value:int32\n    | LBool of value:bool\n\ntype public Exp =\n    | EVar of name:string\n    | ELit of literal:Lit\n    | EApp of func:Exp * arg:Exp\n    | EAbs of name:string * expr:Exp\n    | ELet of name:string * expr:Exp * body:Exp\n    | EFix of func:string * name:string * expr:Exp\n```\n\nResult type type:\n\n```fsharp\ntype public Type =\n    | TVar of name:string\n    | TInt\n    | TBool\n    | TFun of parameterType:Type * resultType:Type\n```\n\nThe inferencer:\n\n```fsharp\ntype public InferAlgorithm =\n    | TopDown\n    | BottomUp\n\n[\u003cAutoOpen\u003e]\nmodule public Inferencer =\n    let infer: InferAlgorithm -\u003e TypeEnv -\u003e Exp -\u003e Type\n```\n\n---\n\n### Requirements\n\n* F# 6.0 or upper\n* NuGet package supported platforms:\n  * net8.0\n  * net7.0\n  * net6.0\n  * net5.0\n  * netcoreapp3.1\n  * netcoreapp2.1\n  * netstandard2.1\n  * netstandard2.0\n  * net48\n  * net461\n\n### License\n\nCopyright (c) Kouji Matsui (@kozy_kekyo, @kekyo2)\n\nLicense under Apache-v2.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkekyo%2Ftypeinferencer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkekyo%2Ftypeinferencer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkekyo%2Ftypeinferencer/lists"}