Skip to content

Instantly share code, notes, and snippets.

View dan-zheng's full-sized avatar
🥛
우유맛

Dan Zheng dan-zheng

🥛
우유맛
View GitHub Profile
@lattner
lattner / TaskConcurrencyManifesto.md
Last active June 3, 2025 20:55
Swift Concurrency Manifesto
@rxwei
rxwei / staged-y-combinator.swift
Last active July 23, 2017 10:10
Staged Y combinator with NNKit
/// Y combinator
func fix<D, R>(
_ f: @escaping (Rep<(D) -> R>) -> Rep<(D) -> R>) -> Rep<(D) -> R> {
return lambda { d in f(fix(f))[d] }
}
let fac: Rep<(Int) -> Int> = fix { f in
lambda { (n: Rep<Int>) in
.if(n == 0, then: ^1, else: n * f[n - 1])
}
@CTMacUser
CTMacUser / NNNN-fixed-size-arrays.md
Last active April 28, 2021 17:37
Swift proposal for fixed-size array types
@bittlingmayer
bittlingmayer / fasttext_similarity.py
Created June 10, 2017 12:50
Similarity for two files output by fastText print-word-vectors or print-sentence-vectors
"""
Takes two files produced by fastText's print-word-vectors or print-sentence-vectors and compares the vectors by similarity.
(See https://github.com/facebookresearch/fastText.)
This can be useful for benchmarking output or even generating benchmark data.
For example:
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active June 9, 2025 03:17
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@threepointone
threepointone / glam-for-css-folks.md
Last active September 4, 2022 07:43
why css purists will love glam

I made a little styling lib called glam

(some features are in development)

one

let's start off with the simplest use case. we'll make an 'index.html' page, and assume we've setup our js bundler to output bundle.js

@rxwei
rxwei / GADT.swift
Last active November 28, 2024 19:15
GADT in Swift
/// A type equality guarantee is capable of safely casting one value to a
/// different type. It can only be created when `S` and `T` are statically known
/// to be equal.
struct TypeEqualityGuarantee<S, T> {
private init() {}
/// Safely cast a value to the other type.
func cast(_ value: T) -> S {
return value as! S
}

Revisiting Tagless Final Interpreters

Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).

The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?