Skip to content

Commit

Permalink
Merge pull request #324 from sanctuary-js/davidchambers/inline
Browse files Browse the repository at this point in the history
inline `typeEq` and `typeofEq`
  • Loading branch information
davidchambers authored Dec 30, 2023
2 parents 5ea4929 + 6b18e2e commit 4612279
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,6 @@
[]
);

// typeEq :: String -> a -> Boolean
const typeEq = name => x => type (x) === name;

// typeofEq :: String -> a -> Boolean
const typeofEq = typeof_ => x => (
typeof x === typeof_ // eslint-disable-line valid-typeof
);

// functionUrl :: String -> String
const functionUrl = name => {
const version = '0.22.0'; // updated programmatically
Expand Down Expand Up @@ -444,23 +436,23 @@
const AnyFunction = NullaryTypeWithUrl
('Function')
([])
(typeofEq ('function'));
(x => typeof x === 'function');

//# Arguments :: Type
//.
//. Type comprising every [`arguments`][arguments] object.
const Arguments = NullaryTypeWithUrl
('Arguments')
([])
(typeEq ('Arguments'));
(x => type (x) === 'Arguments');

//# Array :: Type -> Type
//.
//. Constructor for homogeneous Array types.
const Array = UnaryTypeWithUrl
('Array')
([])
(typeEq ('Array'))
(x => type (x) === 'Array')
(array => array);

//# Array0 :: Type
Expand Down Expand Up @@ -497,7 +489,7 @@
const Boolean = NullaryTypeWithUrl
('Boolean')
([])
(typeofEq ('boolean'));
(x => typeof x === 'boolean');

//# Buffer :: Type
//.
Expand All @@ -513,7 +505,7 @@
const Date = NullaryTypeWithUrl
('Date')
([])
(typeEq ('Date'));
(x => type (x) === 'Date');

//# ValidDate :: Type
//.
Expand All @@ -529,7 +521,7 @@
const Descending = UnaryTypeWithUrl
('Descending')
([])
(typeEq ('sanctuary-descending/Descending@1'))
(x => type (x) === 'sanctuary-descending/Descending@1')
(descending => descending);

//# Either :: Type -> Type -> Type
Expand All @@ -538,7 +530,7 @@
const Either = BinaryTypeWithUrl
('Either')
([])
(typeEq ('sanctuary-either/Either@1'))
(x => type (x) === 'sanctuary-either/Either@1')
(either => either.isLeft ? [either.value] : [])
(either => either.isLeft ? [] : [either.value]);

Expand All @@ -549,7 +541,7 @@
const Error = NullaryTypeWithUrl
('Error')
([])
(typeEq ('Error'));
(x => type (x) === 'Error');

//# Fn :: Type -> Type -> Type
//.
Expand Down Expand Up @@ -611,7 +603,7 @@
const Identity = UnaryTypeWithUrl
('Identity')
([])
(typeEq ('sanctuary-identity/Identity@1'))
(x => type (x) === 'sanctuary-identity/Identity@1')
(identity => identity);

//# JsMap :: Type -> Type -> Type
Expand Down Expand Up @@ -642,7 +634,7 @@
const Maybe = UnaryTypeWithUrl
('Maybe')
([])
(typeEq ('sanctuary-maybe/Maybe@1'))
(x => type (x) === 'sanctuary-maybe/Maybe@1')
(maybe => maybe);

//# Module :: Type
Expand Down Expand Up @@ -673,7 +665,7 @@
const Null = NullaryTypeWithUrl
('Null')
([])
(typeEq ('Null'));
(x => type (x) === 'Null');

//# Nullable :: Type -> Type
//.
Expand All @@ -691,7 +683,7 @@
const Number = NullaryTypeWithUrl
('Number')
([])
(typeofEq ('number'));
(x => typeof x === 'number');

const nonZero = x => x !== 0;
const nonNegative = x => x >= 0;
Expand Down Expand Up @@ -819,15 +811,15 @@
const Object = NullaryTypeWithUrl
('Object')
([])
(typeEq ('Object'));
(x => type (x) === 'Object');

//# Pair :: Type -> Type -> Type
//.
//. [Pair][] type constructor.
const Pair = BinaryTypeWithUrl
('Pair')
([])
(typeEq ('sanctuary-pair/Pair@1'))
(x => type (x) === 'sanctuary-pair/Pair@1')
(pair => [pair.fst])
(pair => [pair.snd]);

Expand All @@ -837,7 +829,7 @@
const RegExp = NullaryTypeWithUrl
('RegExp')
([])
(typeEq ('RegExp'));
(x => type (x) === 'RegExp');

//# GlobalRegExp :: Type
//.
Expand Down Expand Up @@ -877,7 +869,7 @@
const String = NullaryTypeWithUrl
('String')
([])
(typeofEq ('string'));
(x => typeof x === 'string');

//# RegexFlags :: Type
//.
Expand All @@ -902,31 +894,31 @@
const Symbol = NullaryTypeWithUrl
('Symbol')
([])
(typeofEq ('symbol'));
(x => typeof x === 'symbol');

//# Type :: Type
//.
//. Type comprising every `Type` value.
const Type = NullaryTypeWithUrl
('Type')
([])
(typeEq ('sanctuary-def/Type@1'));
(x => type (x) === 'sanctuary-def/Type@1');

//# TypeClass :: Type
//.
//. Type comprising every [`TypeClass`][] value.
const TypeClass = NullaryTypeWithUrl
('TypeClass')
([])
(typeEq ('sanctuary-type-classes/TypeClass@1'));
(x => type (x) === 'sanctuary-type-classes/TypeClass@1');

//# Undefined :: Type
//.
//. Type whose sole member is `undefined`.
const Undefined = NullaryTypeWithUrl
('Undefined')
([])
(typeEq ('Undefined'));
(x => type (x) === 'Undefined');

//# env :: Array Type
//.
Expand Down

0 comments on commit 4612279

Please sign in to comment.