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
| namespace PhantomTypes | |
| module User = | |
| type Username<'a> = private Username of string with | |
| member u.Value = let (Username username) = u in username | |
| type Short = interface end | |
| type Full = interface end |
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
| module GADTMotivation | |
| (* | |
| Here is a simple motivational example for GADTs and their usefulness for library design and domain modeling. Suppose we | |
| need to work with settings which can be displayed and adjusted in a GUI. The set of possible setting "types" is fixed | |
| and known in advance: integers, strings and booleans (check-boxes). | |
| The GUI should show an example value for each possible setting type, e.g. 1337 for an integer setting and "Hello" for a | |
| string setting. How can we model this small domain of setting types and computing example values? | |
| *) |
NewerOlder