Phantom types in Swift

This page summarizes the projects mentioned and recommended in the original post on /r/swift

Our great sponsors
  • Appwrite - The open-source backend cloud platform
  • Revelo Payroll - Free Global Payroll designed for tech teams
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • Onboard AI - Learn any GitHub repo in 59 seconds
  • SonarQube - Static code analysis for 29 languages.
  • silt

    An in-progress fast, dependently typed, functional programming language implemented in Swift.

    This is absolutely one of my favorite patterns. I really like using it to build state machines. Each state has a constrained extension full of behaviors and a method you can use to transit to the next state that just scoops all the data into a new container with a different tag. A light extension of that pattern is to then use associated/nested types dependent on the tags to define other behaviors such as custom state associated with each point in the machine. Conversely, behaviors common to every state can be added via an extension as per usual. Here’s a big hairy TypeChecker written following this pattern with its implementation split across an entire modules’ worth of files. Each transition point from elaboration to type checking to type inference is neatly contained by the tag which uniquely determines the state carried at each point.

  • CompCert

    The CompCert formally-verified C compiler

    Yes, it is a false dichotomy to suggest one does not need tests because one has types. One needs both in systems of sufficient complexity. Even CompCert has a test suite, and it’s got a full formal proof of its own correctness!

  • Appwrite

    Appwrite - The open-source backend cloud platform. The open-source backend cloud platform for developing Web, Mobile, and Flutter applications. You can set up your backend faster with real-time APIs for authentication, databases, file storage, cloud functions, and much more!

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts