Scalqa supports a concept of "void object" ("empty object"), which can be defined for any type. This is similar to Null Object Pattern.
Unlike "null", void object can have methods invoked, getting some behavior pertinent to 'voidness'
- Void Stream is a singleton object of empty stream, which can be re-used for any type
- Void Opt, is a singleton optional value with no value, which can be re-used for any type
- Void String, is a string of zero length, which can be re-used for String type instead of null
- scala.Nil is a void instance, re-used for all parameterized scala.List types
Void objects have a standard way to declare their voidness by mixing this Void trait.
Alternatively, Able.Void trait can be mixed and
"def isVoid" test added explicitly.
For standard opaque types
"def value_isVoid" has to be overridden in companion object.
Types with void values have to define implicit conversions from \/.
class Foo object Foo: val void = new Foo with Void implicit inline def implicitRequest(v:VOID): Foo = void // Standard void assignment is: val v: Foo=VOID
A standard way to test for voidness is universal
.isVoid method available for all types (including opaque).