DependentTypes
Dependent types are types that depend on inhabitants of other types. As an example, consider a type that defines all the strings less than a particular length. This type would depend on the specified length, which is itself an instance of another type (e.g. int).
This library allows us to encode those rules about what constitutes a valid subset of a primitive type into a specific type in your domain. Using this library, you can create such a constrained string (i.e. BoundedString), as well as constrained numeric types.
PM> Install-Package FSharp.DependentTypes
Example
A simple example of constraining a string and a numeric type:
1: 2: 3: 4: 5: 6: 7: 8: |
|
Samples & documentation
Tutorial contains a further explanation of this sample library.
- TODO a fully worked domain model
Contributing and copyright
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding a new public API, please also consider adding samples that can be turned into documentation.
The library is available under MIT license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.
Full name: Index.ProductDescription
Full name: Index.VolumeLevel