Last active
December 14, 2019 18:13
-
-
Save kasperpeulen/b9ac0d3d53d751ccd2166cf3064c9e5c to your computer and use it in GitHub Desktop.
What is algebraic about algebraic data types?
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 TastyFruit = { fruit: 'blueberry' | 'raspberry' } & { portion: 3 | 5 | 7 | 11 } & { tasty: true }; | |
type SomeTimesTasty = { fruit: 'orange' | 'banana' } & { portion: 1 | 2 } & { tasty: boolean }; | |
type NastyFruit = { fruit: 'lemon' } & { portion?: 1 } & { tasty: false }; | |
type Fruit = TastyFruit | SomeTimesTasty | NastyFruit; | |
const numberOfUniqueInstances = (2 * 4 * 1) + (2 * 2 * 2) + (1 * 2 * 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment