Something small I have been working on to enhance basic types with type-safe wrappers to enforce invariants at compile time. Reading valid values from configuration was the initial driver for me to experiment with this.
I have just seen that @bvenners is working on something similar in Scalactic
- https://twitter.com/bvenners/status/529913792822394881
- https://github.com/scalatest/scalatest/tree/master/src/main/scala/org/scalactic/numbers
I really like his approach, here is a quick comparison with Scalactic's version
- it includes versions for Long, Float and Double; I just include Int
- it uses macros to ensure that basic construction only uses a valid Literal (this is an awesome idea!!!!)