This project is a language-agnostic typechecker. It is designed to be abstract from any particular language, but rather provide a framework that language-implementers can use to handle typechecking their statically-typed languages.
This project was created out of my own need for a typechecker for my own compiler for pseudocode (soon to be open-sourced). I decide to separate the typechecker firstly so it could be easily tested as a different project, and secondly so I, and others, could use it for other projects in the future and benefit from any improvements made to this library over time. You can see other projects using the project on the THIRD_PARTY.md
file in this repo.
To save this document from getting too long, this has been moved to a separate document, GettingStarted.md
, found in this repo. This goes over the API at a high-level. For more examples, you can find tests in the test/
folder.
Code style is checked by clang-tidy (ON by default). You can check it by running with:
cd ${PROJECT_ROOT}/build
cmake -DENABLE_CLANG_TIDY=ON ..
The supported build tool is CMake. All of the CMake build options have been placed in a single file, which you can view here: CMake Build Options
Currently being tested using Travis CI on Windows, Mac, and Ubuntu, compiling with:
- MSVC
- gcc
- clang
Typecheck requires C++17.
This library is designed to generally use versions of libraries pre-installed on your system, but if they are not available, build them from source automatically. Libraries this project depends on:
- Catch2 (only for testing)
This project was build for, and is used in my own project: Pseudocode (Soon to be opensourced, if not already.)
fetch_extern(typecheck https://github.com/mattpaletta/typecheck master)
I use FetchContent
to along with a helper function to grab this library. You can see that function here: fetch_extern.
Alternatively, you can add it as a git submodule include the directory:
add_subdirectory(typecheck)
You can then link it to your project:
add_library(my_library ...)
target_link_libraries(my_library PUBLIC ... typecheck ...)
I welcome contributions of all sorts. I consider myself new to the open-source community, so if you're looking for things to contribute, here are some ideas to get started:
- Spelling errors in comments & variable names
- Improve test coverage + add edge cases (build with
ENABLE_COVERAGE
) - Improvements on performance, readability, etc.
- Suggestions or ideas of larger improvements (leave an issue, and we can discuss)
- Improvements to documentation or code comments to add or update where relevant
The algorithm used in this project are heavily influenced by the Hindley-Milner type system and the Swift type checker. Some of the excellent resources used are listed below:
- Hildley-Milner Type System (Wiki)
- Hindley-Milner Interfence - Write You A Haskell - Stephen Diehl
- Exponential time complexity in the Swift type checker
- Type Checker Design & Implementation - Apple Swift 2.2 Docs
If you have any questions, comments, or concerns please leave them in the GitHub Issues Tracker
If you discover any bugs, feel free to create an issue on GitHub. Please add as much information as possible to help us fixing the possible bug. We also encourage you to help even more by forking and sending us a pull request.
- Matthew Paletta (https://github.com/mattpaletta)
GPL-3.0 License. Copyright 2020 Matthew Paletta. http://mrated.ca