- Create a
Producttype class. - Create an existential type
SomeProductfor theProducttype class. - Create a
Factorytype class with acreateProductmethod.
This file contains hidden or 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'; |