- Create a
Product
type class. - Create an existential type
SomeProduct
for theProduct
type class. - Create a
Factory
type class with acreateProduct
method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Assert = (condition: boolean, message: string) => asserts condition; | |
const assert: Assert = (condition, message) => { | |
if (!condition) throw new Error(message); | |
}; | |
type List<A> = Cons<A> | Empty; | |
interface Cons<out A> { | |
type: 'Cons'; |