Author: Chris Lattner
/// 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]) | |
} |
- Proposal: SE-NNNN
- Authors: Daryle Walker, Author 2
- Review Manager: TBD
- Status: Awaiting review
During the review process, add the following fields as needed:
- Decision Notes: Rationale, Additional Commentary
""" | |
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: |
I made a little styling lib called glam
(some features are in development)
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
/// 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 | |
} |
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.
- By Edmond Lau
- Highly Recommended 👍
- http://www.theeffectiveengineer.com/