If the smart constructor's predicate fails, ideally the unsafe constructor throws instead of lifting an invalid value to the newtype. This acts as a small convenience over the consumer having to unsafely unwrap the Option themselves, and we can provide a consistent error message.
If the smart constructor's predicate fails, ideally the unsafe constructor throws instead of lifting an invalid value to the newtype. This acts as a small convenience over the consumer having to unsafely unwrap the
Option
themselves, and we can provide a consistent error message.A bit of Haskell prior art: https://wiki.haskell.org/Smart_constructors#Smart.28er.29_constructors