diff --git a/index.js b/index.js index 349cda1..71499fd 100644 --- a/index.js +++ b/index.js @@ -531,6 +531,18 @@ var Unknown = _Type (UNKNOWN, '', '', 0, always2 ('Unknown'), [], K (K (true)), []); + //# Void :: Type + //. + //. Uninhabited type. + //. + //. May be used to convey that a type parameter of an algebraic data type + //. will not be used. For example, a future of type `Future Void String` + //. will never be rejected. + var Void = NullaryTypeWithUrl + ('Void') + ([]) + (K (false)); + //# Any :: Type //. //. Type comprising every JavaScript value. @@ -2859,6 +2871,7 @@ TypeClass: TypeClass, Undefined: Undefined, Unknown: Unknown, + Void: Void, env: env, create: def ('create') diff --git a/test/index.js b/test/index.js index cff37a8..75d958c 100644 --- a/test/index.js +++ b/test/index.js @@ -1408,6 +1408,18 @@ Since there is no type of which all the above values are members, the type-varia `)); }); + test ('provides the "Void" type', () => { + eq ($.Void.name) ('Void'); + eq ($.Void.url) (`https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Void`); + eq ($.Void.supertypes) ([]); + + const isVoid = $.test ([]) ($.Void); + eq (isVoid (undefined)) (false); + eq (isVoid (null)) (false); + eq (isVoid (NaN)) (false); + eq (isVoid ('')) (false); + }); + test ('provides the "Any" type', () => { eq ($.Any.name) ('Any'); eq ($.Any.url) (`https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Any`);