(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // This example shows how higher-kinded types can be emulated in Swift today. | |
| // It acheives correct typing at the cost of some boilerplate, manual lifting and an existential representation. | |
| // The technique below was directly inspired by the paper Lightweight Higher-Kinded Polymorphism | |
| // by Jeremy Yallop and Leo White found at http://ocamllabs.io/higher/lightweight-higher-kinded-polymorphism.pdf | |
| /// `ConstructorTag` represents a type constructor. | |
| /// `Argument` represents an argument to the type constructor. | |
| struct Apply<ConstructorTag, Argument> { | |
| /// An existential containing a value of `Constructor<Argument>` | |
| /// Where `Constructor` is the type constructor represented by `ConstructorTag` |
| /// Playground - noun: a place where people can play | |
| /// I am the very model of a modern Judgement General | |
| //: # Algorithm W | |
| //: In this playground we develop a complete implementation of the classic | |
| //: algorithm W for Hindley-Milner polymorphic type inference in Swift. | |
| //: ## Introduction |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.