Skip to content

Commit

Permalink
Merge pull request #280 from sanctuary-js/davidchambers/void
Browse files Browse the repository at this point in the history
types: define Void
  • Loading branch information
davidchambers authored Jan 13, 2020
2 parents 80f5b9e + dfa436a commit 267f848
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 @@ -2859,6 +2871,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 267f848

Please sign in to comment.