{"id":16348968,"url":"https://github.com/sheaf/ghc-tcplugin-api","last_synced_at":"2025-03-21T00:30:30.490Z","repository":{"id":43645715,"uuid":"377270129","full_name":"sheaf/ghc-tcplugin-api","owner":"sheaf","description":"An interface for GHC type-checking plugins","archived":false,"fork":false,"pushed_at":"2023-08-29T19:28:01.000Z","size":251,"stargazers_count":20,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-24T07:48:52.493Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sheaf.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"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-06-15T19:15:16.000Z","updated_at":"2024-04-03T03:11:06.000Z","dependencies_parsed_at":"2024-10-11T01:06:19.976Z","dependency_job_id":null,"html_url":"https://github.com/sheaf/ghc-tcplugin-api","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":"0.018867924528301883","last_synced_commit":"93a28bbe22bd408bc7a2b56a9f17393977989b77"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheaf%2Fghc-tcplugin-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheaf%2Fghc-tcplugin-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheaf%2Fghc-tcplugin-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheaf%2Fghc-tcplugin-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sheaf","download_url":"https://codeload.github.com/sheaf/ghc-tcplugin-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244094204,"owners_count":20397020,"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":[],"created_at":"2024-10-11T00:56:15.476Z","updated_at":"2025-03-21T00:30:30.178Z","avatar_url":"https://github.com/sheaf.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# ghc-tcplugin-api \u003ca href=\"https://hackage.haskell.org/package/ghc-tcplugin-api\" alt=\"Hackage\"\u003e\u003cimg src=\"https://img.shields.io/hackage/v/ghc-tcplugin-api.svg\" /\u003e\u003c/a\u003e\n\nThis library provides a convenient and cross-compatible interface for authors\nof GHC type-checking plugins (starting from GHC 8.8).    \n\nDifferent stages of a type-checking plugin (initialisation, solving, rewriting, shutdown) are given\ndifferent monads to operate within. This ensures operations that only make sense in one context\naren't mistakenly carried out in another.    \n\nTo provide a unified interface to these monads (whenever this makes sense), two MTL-style typeclasses\nare provided: `MonadTcPlugin` and `MonadTcPluginWork`.    \n\n- `MonadTcPlugin` enables overloading of monadic operations common to all stages,\n  such as lifting `IO` operations or performing name resolution.    \n  `MonadTcPlugin` is internally implemented using lifting and unlifting of GHC's `TcM` monad,\n  but it is hoped that users will not need to access these internals.    \n\n- `MonadTcPluginWork` allows plugins to emit new work (additional constraints for GHC to process),\n  including throwing custom type errors. These operations are only available in the solving\n  and rewriting stages of a type-checking plugin.    \n  Helpers for throwing custom type-errors are also provided, by means of the datatype\n  `TcPluginErrorMessage` (which mimics the `ErrorMessage` datakind from `GHC.TypeLits`) and the\n  interpreter `mkTcPluginErrorTy`.    \n\n## Discoverability\n\nOne goal of this library is to ensure that authors of type-checking plugins should, for the most part,\nonly need to import this library for their type-checking plugin needs, and not the `ghc` package itself.    \nThis should assist discoverability: instead of having to trawl through the entire GHC codebase,\nnew users should be able to determine at a glance what functions might be appropriate for their\nusecase using this library's interface. This can be particularly useful when using typed holes.\n\n## Compatibility\n\nThis library provides a unified interface that works across different GHC versions (starting from GHC 8.8),\naiming to reduce the CPP burden imposed on authors of type-checking plugins.    \n\nWe make use of GHC's new API for rewriting type-families in typechecker plugins,\nwhich was part of GHC 9.4.    \nA compatibility layer is provided, which retro-fits the rewriting functionality onto\nprevious versions of GHC.\n\n## Documentation\n\nThe [package documentation](https://hackage.haskell.org/package/ghc-tcplugin-api) includes an overview of type-checking plugins,\nand should provide a good starting point for anyone interested in writing a type-checking plugin.\n\n## Examples\n\nA simple example plugin which rewrites type family applications, emitting wanted constraints and\nthrowing custom type errors as it goes, is provided [here](examples/RewriterPlugin/plugin/RewriterPlugin.hs).    \n\nA more complex example, that of type-checking an intrinsically typed System F, is provided\n[here](examples/SystemF/src/SystemF/Plugin.hs). This implements the equational theory of the confluent calculus\nof explicit substitutions from the paper [_Confluence properties of weak and strong calculi of explicit substitutions_](https://hal.inria.fr/inria-00077189):\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"img/substitution_calculus.png\" alt=\"Rewrite rules for the confluent calculus of substitutions\" /\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheaf%2Fghc-tcplugin-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsheaf%2Fghc-tcplugin-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheaf%2Fghc-tcplugin-api/lists"}