Skip to content

Commit

Permalink
types: define Void
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed Jan 8, 2020
1 parent b28e2d7 commit 5ac6d4d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -2820,6 +2832,7 @@
TypeClass: TypeClass,
Undefined: Undefined,
Unknown: Unknown,
Void: Void,
env: env,
create:
def ('create')
Expand Down
12 changes: 12 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down

0 comments on commit 5ac6d4d

Please sign in to comment.