Skip to content

Instantly share code, notes, and snippets.

View filip-sakel's full-sized avatar

Filip Sakellariou filip-sakel

View GitHub Profile
@filip-sakel
filip-sakel / TypeQualifier-design.md
Last active June 25, 2026 18:07
TypeQualifier Design Outline

Believe it or not, the diagram below is a simplified version 😅. Here's the main idea: you give TypeQualifier some type syntax (no semantic information), and it resolves it to extended nominal types: nominal declarations and all their accessible extensions.

First, we convert the given type syntax to an array of references we can more easily look up; e.g., (Collection & MyProto).Element becomes Collection.Element and MyProto.Element. Then, we split each type reference up into the base type and its member type; in our example, the base is Collection with member type Element. Like all type syntax, Collection depends on its declaration context, so we perform unqualified type lookup to find the referenced type declaration. For now, let’s assume unqualified lookup returns a nominal declaration. If the declaration is nested within an extension, its qualified name depends on the extended type, so we have to recursively resolve that before continuing. For instance, if we don’t resolve the extended type `

@filip-sakel
filip-sakel / TaskRacing.swift
Last active December 6, 2021 07:55
A Swift implementation concurrency structure safely racing two tasks against each other. This structure is useful for implementing operators like `debounce` for `AsyncSequence`.
//
// TaskRacing.swift
//
// Created by Filip Sakel on 21/6/21.
//
import Dispatch
// MARK: - Utilities