diff --git a/eslint/rules/indent.js b/eslint/rules/indent.js index ece7111..6192e3d 100644 --- a/eslint/rules/indent.js +++ b/eslint/rules/indent.js @@ -5,6 +5,7 @@ const common = require ('sanctuary-style/eslint-common.json'); const indent = (JSON.parse (JSON.stringify (common))).rules['indent']; indent[2].ignoredNodes.push ( + 'CallExpression', 'CallExpression > *', 'CallExpression > ArrowFunctionExpression ArrowFunctionExpression > *', 'CallExpression > FunctionExpression > BlockStatement' diff --git a/test/index.js b/test/index.js index 07f58ba..20a86f5 100644 --- a/test/index.js +++ b/test/index.js @@ -29,18 +29,12 @@ function eq(actual) { // notImplemented :: () -> Undefined ! const notImplemented = () => { throw new Error ('Not implemented'); }; -// throws :: (() -> Undefined !) -> TypeRep a -> String -> Undefined ! +// throws :: (() -> Undefined !) -> Error -> Undefined ! function throws(thunk) { assert.strictEqual (arguments.length, throws.length); - return function throws$1(type) { + return function throws$1(expected) { assert.strictEqual (arguments.length, throws$1.length); - return function throws$2(message) { - assert.strictEqual (arguments.length, throws$2.length); - assert.throws ( - thunk, - err => err.constructor === type && err.message === message - ); - }; + assert.throws (thunk, actual => Z.equals (actual, expected)); }; } @@ -245,8 +239,7 @@ suite ('create', () => { test ('type checks its arguments', () => { throws (() => $.create (true)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value create :: { checkTypes :: Boolean, env :: Array Any } -> Function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -255,7 +248,7 @@ create :: { checkTypes :: Boolean, env :: Array Any } -> Function 1) true :: Boolean The value at position 1 is not a member of ‘{ checkTypes :: Boolean, env :: Array Any }’. -`); +`)); }); }); @@ -264,8 +257,7 @@ suite ('def', () => { test ('type checks its arguments when checkTypes is true', () => { throws (() => def (null)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function -> Function ^^^^^^ @@ -276,11 +268,10 @@ def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function - The value at position 1 is not a member of ‘String’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#String for information about the String type. -`); +`)); throws (() => def ('') (null)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function -> Function ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -291,11 +282,10 @@ def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function - The value at position 1 is not a member of ‘StrMap (Array TypeClass)’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#StrMap for information about the sanctuary-def/StrMap type. -`); +`)); throws (() => def ('') ({}) ([])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function -> Function ^^^^^^^^^^^^^^^^^^^^^ @@ -306,11 +296,10 @@ def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function - The value at position 1 is not a member of ‘NonEmpty (Array Type)’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#NonEmpty for information about the sanctuary-def/NonEmpty type. -`); +`)); throws (() => def ('') ({}) ([1, 2, 3])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function -> Function ^^^^ @@ -321,11 +310,10 @@ def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function - The value at position 1 is not a member of ‘Type’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Type for information about the Type type. -`); +`)); throws (() => def ('') ({}) ([$.Null]) (null)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function -> Function ^^^^^^^^ @@ -336,7 +324,7 @@ def :: String -> StrMap (Array TypeClass) -> NonEmpty (Array Type) -> Function - The value at position 1 is not a member of ‘Function’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Function for information about the Function type. -`); +`)); }); test ('does not type check its arguments when checkTypes is false', () => { @@ -386,13 +374,13 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Function for eq ($1 (1)) ([1]); eq ($2 (1) (2)) ([1, 2]); eq ($3 (1) (2) (3)) ([1, 2, 3]); - eq ($26 (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) (24) (25) (26)) ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]); + eq ($26 (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) (24) (25) (26)) + ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]); }); test ('returns a function which throws if given too many args', () => { throws (() => $0 (1)) - (TypeError) - (`‘$0’ applied to the wrong number of arguments + (new TypeError (`‘$0’ applied to the wrong number of arguments $0 :: () -> Array a ^^ @@ -401,11 +389,10 @@ $0 :: () -> Array a Expected zero arguments but received one argument: - 1 -`); +`)); throws (() => $1 (1, 2)) - (TypeError) - (`‘$1’ applied to the wrong number of arguments + (new TypeError (`‘$1’ applied to the wrong number of arguments $1 :: a -> Array a ^ @@ -415,11 +402,10 @@ Expected one argument but received two arguments: - 1 - 2 -`); +`)); throws (() => $2 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) - (TypeError) - (`‘$2’ applied to the wrong number of arguments + (new TypeError (`‘$2’ applied to the wrong number of arguments $2 :: a -> a -> Array a ^ @@ -437,7 +423,7 @@ Expected one argument but received 10 arguments: - 8 - 9 - 10 -`); +`)); }); test ('returns a function which type checks its arguments', () => { @@ -457,8 +443,7 @@ Expected one argument but received 10 arguments: (_1 => _2 => _3 => _4 => _5 => _6 => _7 => _8 => _9 => [_1, _2, _3, _4, _5, _6, _7, _8, _9]); throws (() => $9 ('X')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Array Number ^^^^^^ @@ -469,11 +454,10 @@ $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Numb The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => $9 (1) ('X')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Array Number ^^^^^^ @@ -484,11 +468,10 @@ $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Numb The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => $9 (1) (2) ('X')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Array Number ^^^^^^ @@ -499,11 +482,10 @@ $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Numb The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => $9 (1) (2) (3) ('X')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Array Number ^^^^^^ @@ -514,11 +496,10 @@ $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Numb The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => $9 (1) (2) (3) (4) ('X')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Array Number ^^^^^^ @@ -529,11 +510,10 @@ $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Numb The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => $9 (1) (2) (3) (4) (5) ('X')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Array Number ^^^^^^ @@ -544,11 +524,10 @@ $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Numb The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => $9 (1) (2) (3) (4) (5) (6) ('X')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Array Number ^^^^^^ @@ -559,11 +538,10 @@ $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Numb The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => $9 (1) (2) (3) (4) (5) (6) (7) ('X')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Array Number ^^^^^^ @@ -574,11 +552,10 @@ $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Numb The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => $9 (1) (2) (3) (4) (5) (6) (7) (8) ('X')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Array Number ^^^^^^ @@ -589,7 +566,7 @@ $9 :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Numb The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); eq ($9 (1) (2) (3) (4) (5) (6) (7) (8) (9)) ([1, 2, 3, 4, 5, 6, 7, 8, 9]); }); @@ -605,8 +582,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for in eq (sqrt (25)) (5); throws (() => sqrt (null)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value sqrt :: Number -> Number ^^^^^^ @@ -617,11 +593,10 @@ sqrt :: Number -> Number The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => sqrt (undefined)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value sqrt :: Number -> Number ^^^^^^ @@ -632,7 +607,7 @@ sqrt :: Number -> Number The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); }); test ('reports type error correctly for parameterized types', () => { @@ -675,8 +650,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for in (x => y => z => x); throws (() => a00 (1) ('a')) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation a00 :: a -> a -> a ^ ^ @@ -687,11 +661,10 @@ a00 :: a -> a -> a 2) "a" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => a00 (1) (['a'])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation a00 :: a -> a -> a ^ ^ @@ -702,11 +675,10 @@ a00 :: a -> a -> a 2) ["a"] :: Array String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => a00 (1) (Just (1))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation a00 :: a -> a -> a ^ ^ @@ -717,11 +689,10 @@ a00 :: a -> a -> a 2) Just(1) :: Maybe Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => a01 (1) (['a', 'b'])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation a01 :: a -> Array a -> a ^ ^ @@ -733,11 +704,10 @@ a01 :: a -> Array a -> a "b" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => a01 ([1, 2]) ([1, 2, 3, 4])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation a01 :: a -> Array a -> a ^ ^ @@ -751,11 +721,10 @@ a01 :: a -> Array a -> a 4 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => a01 ([1, 2]) ([['a', 'b'], ['c', 'd']])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation a01 :: a -> Array a -> a ^ ^ @@ -767,11 +736,10 @@ a01 :: a -> Array a -> a ["c", "d"] :: Array String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => a01 ([[1, 2], [3, 4]]) ([[1, 2], [3, 4]])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation a01 :: a -> Array a -> a ^ ^ @@ -783,11 +751,10 @@ a01 :: a -> Array a -> a [3, 4] :: Array Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => a02 ([1, 2]) ([[1, 2], [3, 4, 5, 6]])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation a02 :: a -> Array (Array a) -> a ^ ^ @@ -803,11 +770,10 @@ a02 :: a -> Array (Array a) -> a 6 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => ab02e (1) ('x') ([[Left ('a'), Left ('b')], [Left ('c'), Left ('d')]])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation ab02e :: a -> b -> Array (Array (Either a b)) -> a ^ ^ @@ -821,11 +787,10 @@ ab02e :: a -> b -> Array (Array (Either a b)) -> a "d" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => ab02e (1) ('x') ([[Right (1), Right (2)], [Right (3), Right (4)]])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation ab02e :: a -> b -> Array (Array (Either a b)) -> a ^ ^ @@ -839,11 +804,10 @@ ab02e :: a -> b -> Array (Array (Either a b)) -> a 4 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => ab0e21 (1) ('x') (Left ([['a', 'b'], ['c', 'd']]))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation ab0e21 :: a -> b -> Either (Array (Array a)) (Array b) -> a ^ ^ @@ -857,11 +821,10 @@ ab0e21 :: a -> b -> Either (Array (Array a)) (Array b) -> a "d" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => ab0e21 (1) ('x') (Right ([1, 2]))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation ab0e21 :: a -> b -> Either (Array (Array a)) (Array b) -> a ^ ^ @@ -873,7 +836,7 @@ ab0e21 :: a -> b -> Either (Array (Array a)) (Array b) -> a 2 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('throws custom error for unrecognized value (empty env)', () => { @@ -888,8 +851,7 @@ Since there is no type of which all the above values are members, the type-varia (x => x); throws (() => id (/xxx/)) - (TypeError) - (`Unrecognized value + (new TypeError (`Unrecognized value id :: a -> a ^ @@ -898,7 +860,7 @@ id :: a -> a 1) /xxx/ :: (no types) The environment is empty! Polymorphic functions require a non-empty environment. -`); +`)); }); test ('throws custom error for unrecognized value (non-empty env)', () => { @@ -913,8 +875,7 @@ The environment is empty! Polymorphic functions require a non-empty environment. (x => x); throws (() => id (/xxx/)) - (TypeError) - (`Unrecognized value + (new TypeError (`Unrecognized value id :: a -> a ^ @@ -930,7 +891,7 @@ The environment contains the following types: - Boolean - Number - String -`); +`)); }); test ('returns a function which type checks its return value', () => { @@ -942,8 +903,7 @@ The environment contains the following types: (x => y => 'XXX'); throws (() => add (2) (2)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value add :: Number -> Number -> Number ^^^^^^ @@ -954,7 +914,7 @@ add :: Number -> Number -> Number The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); }); test ('performs type checking when a "returned" function is applied', () => { @@ -970,8 +930,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for in eq (lt (1) (2)) (false); throws (() => lt (123) ('abc')) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation lt :: Ord a => a -> (a -> Boolean) ^ ^ @@ -982,7 +941,7 @@ lt :: Ord a => a -> (a -> Boolean) 2) "abc" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('does not rely on constructor identity', () => { @@ -1026,8 +985,7 @@ Since there is no type of which all the above values are members, the type-varia z.push (z); throws (() => id (z)) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation id :: a -> a ^ @@ -1036,7 +994,7 @@ id :: a -> a 1) [] :: Array ??? Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('supports custom types', () => { @@ -1048,8 +1006,7 @@ Since there is no type of which all the above values are members, the type-varia (x => maybe => maybe.isJust ? maybe.value : x); throws (() => fromMaybe ('x') (Just (null))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation fromMaybe :: a -> Maybe a -> a ^ ^ @@ -1060,7 +1017,7 @@ fromMaybe :: a -> Maybe a -> a 2) null :: Null Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('supports enumerated types', () => { @@ -1091,8 +1048,7 @@ Since there is no type of which all the above values are members, the type-varia }); throws (() => convertTo ('days') (new Date (0))) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value convertTo :: TimeUnit -> ValidDate -> ValidNumber ^^^^^^^^ @@ -1101,7 +1057,7 @@ convertTo :: TimeUnit -> ValidDate -> ValidNumber 1) "days" :: String The value at position 1 is not a member of ‘TimeUnit’. -`); +`)); eq (convertTo ('seconds') (new Date (1000))) (1); @@ -1131,8 +1087,7 @@ The value at position 1 is not a member of ‘TimeUnit’. eq (id (['foo', true])) (['foo', true]); throws (() => id (['foo', false])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation id :: a -> a ^ @@ -1141,7 +1096,7 @@ id :: a -> a 1) ["foo", false] :: Array ??? Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('supports record types', () => { @@ -1179,8 +1134,7 @@ Since there is no type of which all the above values are members, the type-varia eq (length ({start: {x: 1, y: 1}, end: {x: 4, y: 5, color: 'red'}})) (5); throws (() => dist (null)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value dist :: { x :: Number, y :: Number } -> { x :: Number, y :: Number } -> Number ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1189,11 +1143,10 @@ dist :: { x :: Number, y :: Number } -> { x :: Number, y :: Number } -> Number 1) null :: Null The value at position 1 is not a member of ‘{ x :: Number, y :: Number }’. -`); +`)); throws (() => dist ({})) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value dist :: { x :: Number, y :: Number } -> { x :: Number, y :: Number } -> Number ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1202,11 +1155,10 @@ dist :: { x :: Number, y :: Number } -> { x :: Number, y :: Number } -> Number 1) {} :: Object, StrMap a The value at position 1 is not a member of ‘{ x :: Number, y :: Number }’. -`); +`)); throws (() => dist ({x: 0})) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value dist :: { x :: Number, y :: Number } -> { x :: Number, y :: Number } -> Number ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1215,11 +1167,10 @@ dist :: { x :: Number, y :: Number } -> { x :: Number, y :: Number } -> Number 1) {"x": 0} :: Object, StrMap Number The value at position 1 is not a member of ‘{ x :: Number, y :: Number }’. -`); +`)); throws (() => dist ({x: 0, y: null})) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value dist :: { x :: Number, y :: Number } -> { x :: Number, y :: Number } -> Number ^^^^^^ @@ -1230,11 +1181,10 @@ dist :: { x :: Number, y :: Number } -> { x :: Number, y :: Number } -> Number The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); throws (() => length ({start: 0, end: 0})) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value length :: { end :: { x :: Number, y :: Number }, start :: { x :: Number, y :: Number } } -> Number ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1243,11 +1193,10 @@ length :: { end :: { x :: Number, y :: Number }, start :: { x :: Number, y :: Nu 1) 0 :: Number The value at position 1 is not a member of ‘{ x :: Number, y :: Number }’. -`); +`)); throws (() => length ({start: {x: 0, y: 0}, end: {x: null, y: null}})) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value length :: { end :: { x :: Number, y :: Number }, start :: { x :: Number, y :: Number } } -> Number ^^^^^^ @@ -1258,7 +1207,7 @@ length :: { end :: { x :: Number, y :: Number }, start :: { x :: Number, y :: Nu The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); // id :: a -> a const id = @@ -1270,8 +1219,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for in eq (id ([{x: 0, y: 0}, {x: 1, y: 1}])) ([{x: 0, y: 0}, {x: 1, y: 1}]); throws (() => $.RecordType ({x: /XXX/, y: /XXX/, z: $.Any})) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value RecordType :: StrMap Type -> Type ^^^^ @@ -1282,7 +1230,7 @@ RecordType :: StrMap Type -> Type The value at position 1 is not a member of ‘Type’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Type for information about the Type type. -`); +`)); // Foo :: Type const Foo = $.RecordType ({x: a, y: a}); @@ -1297,8 +1245,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Type for info eq (foo ({x: 1, y: 2, z: 3})) ({x: 1, y: 2, z: 3}); throws (() => foo ({x: 'abc', y: 123})) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation foo :: { x :: a, y :: a } -> { x :: a, y :: a } ^ ^ @@ -1309,7 +1256,7 @@ foo :: { x :: a, y :: a } -> { x :: a, y :: a } 2) 123 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('supports "nullable" types', () => { @@ -1318,8 +1265,7 @@ Since there is no type of which all the above values are members, the type-varia eq (String ($.Nullable)) ('Nullable :: Type -> Type'); throws (() => $.Nullable (null)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value Nullable :: Type -> Type ^^^^ @@ -1330,7 +1276,7 @@ Nullable :: Type -> Type The value at position 1 is not a member of ‘Type’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Type for information about the Type type. -`); +`)); // toUpper :: Nullable String -> Nullable String const toUpper = @@ -1343,8 +1289,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Type for info eq (toUpper ('abc')) ('ABC'); throws (() => toUpper (['abc'])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value toUpper :: Nullable String -> Nullable String ^^^^^^ @@ -1355,7 +1300,7 @@ toUpper :: Nullable String -> Nullable String The value at position 1 is not a member of ‘String’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#String for information about the String type. -`); +`)); // defaultTo :: a -> Nullable a -> a const defaultTo = @@ -1368,8 +1313,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#String for in eq (defaultTo (0) (42)) (42); throws (() => defaultTo (0) ('XXX')) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation defaultTo :: a -> Nullable a -> a ^ ^ @@ -1380,7 +1324,7 @@ defaultTo :: a -> Nullable a -> a 2) "XXX" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); // f :: Nullable a -> Nullable a const f = @@ -1393,8 +1337,7 @@ Since there is no type of which all the above values are members, the type-varia eq (f (0)) (42); throws (() => f ('XXX')) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation f :: Nullable a -> Nullable a ^ ^ @@ -1405,7 +1348,7 @@ f :: Nullable a -> Nullable a 2) 42 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('provides the "Any" type', () => { @@ -1481,8 +1424,7 @@ Since there is no type of which all the above values are members, the type-varia eq (snd (['foo', 42])) (42); throws (() => fst (['foo'])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value fst :: Array2 a b -> a ^^^^^^^^^^ @@ -1493,7 +1435,7 @@ fst :: Array2 a b -> a The value at position 1 is not a member of ‘Array2 a b’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Array2 for information about the sanctuary-def/Array2 type. -`); +`)); }); test ('provides the "Boolean" type', () => { @@ -1593,8 +1535,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Array2 for in (date => date.valueOf () / 1000); throws (() => sinceEpoch (new Date ('foo'))) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value sinceEpoch :: ValidDate -> Number ^^^^^^^^^ @@ -1605,7 +1546,7 @@ sinceEpoch :: ValidDate -> Number The value at position 1 is not a member of ‘ValidDate’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#ValidDate for information about the sanctuary-def/ValidDate type. -`); +`)); eq (sinceEpoch (new Date (123456))) (123.456); }); @@ -1873,8 +1814,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#ValidDate for eq (keys (o)) (['x', 'y', 'z']); throws (() => keys ({a: 1, b: 'XXX'})) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation keys :: StrMap a -> Array String ^ @@ -1884,15 +1824,14 @@ keys :: StrMap a -> Array String "XXX" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); eq (values ({})) ([]); eq (values ({x: 1, y: 2, z: 3})) ([1, 2, 3]); eq (values (o)) ([1, 2, 3]); throws (() => values ({a: 1, b: 'XXX'})) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation values :: StrMap a -> Array a ^ @@ -1902,7 +1841,7 @@ values :: StrMap a -> Array a "XXX" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); // testUnaryType :: Array (StrMap Number) -> Array (StrMap Number) const testUnaryType = @@ -1914,8 +1853,7 @@ Since there is no type of which all the above values are members, the type-varia eq (testUnaryType ([{x: 1}, {y: 2}, {z: 3}])) ([{x: 1}, {y: 2}, {z: 3}]); throws (() => testUnaryType ([{x: /xxx/}])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value testUnaryType :: Array (StrMap Number) -> Array (StrMap Number) ^^^^^^ @@ -1926,7 +1864,7 @@ testUnaryType :: Array (StrMap Number) -> Array (StrMap Number) The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); // testBinaryType :: Either a (StrMap b) -> Either a (StrMap b) const testBinaryType = @@ -1939,8 +1877,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for in eq (testBinaryType (Right ({x: 1, y: 2, z: 3}))) (Right ({x: 1, y: 2, z: 3})); throws (() => testBinaryType (Right ({x: ['foo', false]}))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation testBinaryType :: Either a (StrMap b) -> Either a (StrMap b) ^ @@ -1949,7 +1886,7 @@ testBinaryType :: Either a (StrMap b) -> Either a (StrMap b) 1) ["foo", false] :: Array ??? Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('uses Z.toString-like string representations', () => { @@ -1990,8 +1927,7 @@ Since there is no type of which all the above values are members, the type-varia const x = pair[0]; const types = pair[1]; throws (() => f (x)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value f :: Null -> Null ^^^^ @@ -2002,7 +1938,7 @@ f :: Null -> Null The value at position 1 is not a member of ‘Null’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Null for information about the Null type. -`); +`)); }); }); @@ -2018,8 +1954,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Null for info (x => y => x + y); throws (() => add ([[1], [2]])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value add :: Number -> Number -> Number ^^^^^^ @@ -2030,7 +1965,7 @@ add :: Number -> Number -> Number The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); }); test ('supports polymorphism via type variables', () => { @@ -2059,8 +1994,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for in eq (ab (false) (0)) (Pair (false) (0)); throws (() => aa (0) (/x/)) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation aa :: a -> a -> Pair a a ^ ^ @@ -2071,11 +2005,10 @@ aa :: a -> a -> Pair a a 2) /x/ :: RegExp Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => aa ([Left ('XXX'), 42])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation aa :: a -> a -> Pair a a ^ @@ -2084,7 +2017,7 @@ aa :: a -> a -> Pair a a 1) [Left("XXX"), 42] :: Array ??? Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); // fromMaybe :: a -> Maybe a -> a const fromMaybe = @@ -2097,8 +2030,7 @@ Since there is no type of which all the above values are members, the type-varia eq (fromMaybe (0) (Just (42))) (42); throws (() => fromMaybe (0) ([1, 2, 3])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value fromMaybe :: a -> Maybe a -> a ^^^^^^^ @@ -2109,7 +2041,7 @@ fromMaybe :: a -> Maybe a -> a The value at position 1 is not a member of ‘Maybe a’. See http://example.com/my-package#Maybe for information about the my-package/Maybe type. -`); +`)); // fst :: Pair a b -> a const fst = @@ -2121,8 +2053,7 @@ See http://example.com/my-package#Maybe for information about the my-package/May eq (fst (Pair ('XXX') (42))) ('XXX'); throws (() => fst (['XXX', 42])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value fst :: Pair a b -> a ^^^^^^^^ @@ -2133,7 +2064,7 @@ fst :: Pair a b -> a The value at position 1 is not a member of ‘Pair a b’. See http://example.com/my-package#Pair for information about the my-package/Pair type. -`); +`)); // twin :: Pair a a -> Boolean const twin = @@ -2146,8 +2077,7 @@ See http://example.com/my-package#Pair for information about the my-package/Pair eq (twin (Pair (42) (99))) (false); throws (() => twin (Pair (42) ('XXX'))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation twin :: Pair a a -> Boolean ^ ^ @@ -2158,7 +2088,7 @@ twin :: Pair a a -> Boolean 2) "XXX" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); // concat :: Either a b -> Either a b -> Either a b const concat = @@ -2173,8 +2103,7 @@ Since there is no type of which all the above values are members, the type-varia eq (concat (Right ('ABC')) (Right ('DEF'))) (Right ('ABCDEF')); throws (() => concat (Left ('abc')) (Left ([1, 2, 3]))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation concat :: Either a b -> Either a b -> Either a b ^ ^ @@ -2185,11 +2114,10 @@ concat :: Either a b -> Either a b -> Either a b 2) [1, 2, 3] :: Array Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => concat (Right ('abc')) (Right ([1, 2, 3]))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation concat :: Either a b -> Either a b -> Either a b ^ ^ @@ -2200,7 +2128,7 @@ concat :: Either a b -> Either a b -> Either a b 2) [1, 2, 3] :: Array Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); // f :: a -> a -> a -> a const f = @@ -2210,8 +2138,7 @@ Since there is no type of which all the above values are members, the type-varia ((x, y, z) => x); throws (() => f (Left ('abc')) (Left (/XXX/))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation f :: a -> a -> a -> a ^ ^ @@ -2222,11 +2149,10 @@ f :: a -> a -> a -> a 2) Left(/XXX/) :: Either RegExp b Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => f (Right (123)) (Right (/XXX/))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation f :: a -> a -> a -> a ^ ^ @@ -2237,11 +2163,10 @@ f :: a -> a -> a -> a 2) Right(/XXX/) :: Either b RegExp Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => f (Left ('abc')) (Right (123)) (Left (/XXX/))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation f :: a -> a -> a -> a ^ ^ @@ -2252,11 +2177,10 @@ f :: a -> a -> a -> a 2) Left(/XXX/) :: Either RegExp b Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => f (Left ('abc')) (Right (123)) (Right (/XXX/))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation f :: a -> a -> a -> a ^ ^ @@ -2267,7 +2191,7 @@ f :: a -> a -> a -> a 2) Right(/XXX/) :: Either b RegExp Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('supports arbitrary nesting of types', () => { @@ -2285,8 +2209,7 @@ Since there is no type of which all the above values are members, the type-varia eq (unnest ([[null], [null], [null]])) ([null, null, null]); throws (() => unnest ([1, 2, 3])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value unnest :: Array (Array a) -> Array a ^^^^^^^^^ @@ -2297,7 +2220,7 @@ unnest :: Array (Array a) -> Array a The value at position 1 is not a member of ‘Array a’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Array for information about the Array type. -`); +`)); // concatComplex :: Array (Either String Integer) -> Array (Either String Integer) -> Array (Either String Integer) const concatComplex = @@ -2309,8 +2232,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Array for inf (xs => ys => [Left (/xxx/)]); throws (() => concatComplex ([Left (/xxx/), Right (0), Right (0.1), Right (0.2)])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value concatComplex :: Array (Either String Integer) -> Array (Either String Integer) -> Array (Either String Integer) ^^^^^^ @@ -2321,11 +2243,10 @@ concatComplex :: Array (Either String Integer) -> Array (Either String Integer) The value at position 1 is not a member of ‘String’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#String for information about the String type. -`); +`)); throws (() => concatComplex ([Left ('abc'), Right (0), Right (0.1), Right (0.2)])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value concatComplex :: Array (Either String Integer) -> Array (Either String Integer) -> Array (Either String Integer) ^^^^^^^ @@ -2336,11 +2257,10 @@ concatComplex :: Array (Either String Integer) -> Array (Either String Integer) The value at position 1 is not a member of ‘Integer’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Integer for information about the sanctuary-def/Integer type. -`); +`)); throws (() => concatComplex ([]) ([Left (/xxx/), Right (0), Right (0.1), Right (0.2)])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value concatComplex :: Array (Either String Integer) -> Array (Either String Integer) -> Array (Either String Integer) ^^^^^^ @@ -2351,11 +2271,10 @@ concatComplex :: Array (Either String Integer) -> Array (Either String Integer) The value at position 1 is not a member of ‘String’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#String for information about the String type. -`); +`)); throws (() => concatComplex ([]) ([Left ('abc'), Right (0), Right (0.1), Right (0.2)])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value concatComplex :: Array (Either String Integer) -> Array (Either String Integer) -> Array (Either String Integer) ^^^^^^^ @@ -2366,11 +2285,10 @@ concatComplex :: Array (Either String Integer) -> Array (Either String Integer) The value at position 1 is not a member of ‘Integer’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Integer for information about the sanctuary-def/Integer type. -`); +`)); throws (() => concatComplex ([]) ([])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value concatComplex :: Array (Either String Integer) -> Array (Either String Integer) -> Array (Either String Integer) ^^^^^^ @@ -2381,7 +2299,7 @@ concatComplex :: Array (Either String Integer) -> Array (Either String Integer) The value at position 1 is not a member of ‘String’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#String for information about the String type. -`); +`)); }); test ('does not allow heterogeneous arrays', () => { @@ -2402,8 +2320,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#String for in eq (concat ([Left ('XXX')]) ([Right (42)])) ([Left ('XXX'), Right (42)]); throws (() => concat ([[1, 2, 3], [Left ('XXX'), Right (42)]])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation concat :: Array a -> Array a -> Array a ^ @@ -2413,11 +2330,10 @@ concat :: Array a -> Array a -> Array a [Left("XXX"), Right(42)] :: Array (Either String Number) Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => concat ([[1, 2, 3], [Right (42), Left ('XXX')]])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation concat :: Array a -> Array a -> Array a ^ @@ -2427,7 +2343,7 @@ concat :: Array a -> Array a -> Array a [Right(42), Left("XXX")] :: Array (Either String Number) Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); // concatNested :: Array (Array a) -> Array (Array a) -> Array (Array a) const concatNested = @@ -2437,8 +2353,7 @@ Since there is no type of which all the above values are members, the type-varia (xss => yss => [['a', 'b', 'c'], [1, 2, 3]]); throws (() => concatNested ([['a', 'b', 'c'], [1, 2, 3]])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation concatNested :: Array (Array a) -> Array (Array a) -> Array (Array a) ^ @@ -2452,11 +2367,10 @@ concatNested :: Array (Array a) -> Array (Array a) -> Array (Array a) 3 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => concatNested ([]) ([['a', 'b', 'c'], [1, 2, 3]])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation concatNested :: Array (Array a) -> Array (Array a) -> Array (Array a) ^ @@ -2470,11 +2384,10 @@ concatNested :: Array (Array a) -> Array (Array a) -> Array (Array a) 3 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => concatNested ([]) ([])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation concatNested :: Array (Array a) -> Array (Array a) -> Array (Array a) ^ @@ -2488,7 +2401,7 @@ concatNested :: Array (Array a) -> Array (Array a) -> Array (Array a) 3 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('supports higher-order functions', () => { @@ -2509,8 +2422,7 @@ Since there is no type of which all the above values are members, the type-varia eq (f (s => s.length) (['foo', 'bar', 'baz', 'quux'])) ([3, 3, 3, 4]); throws (() => g (/xxx/)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value g :: (String -> Number) -> Array String -> Array Number ^^^^^^^^^^^^^^^^^^ @@ -2519,11 +2431,10 @@ g :: (String -> Number) -> Array String -> Array Number 1) /xxx/ :: RegExp The value at position 1 is not a member of ‘String -> Number’. -`); +`)); throws (() => g (s => s.length) (['a', 'b', 'c'])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value g :: (String -> Number) -> Array String -> Array Number ^^^^^^ @@ -2534,11 +2445,10 @@ g :: (String -> Number) -> Array String -> Array Number The value at position 1 is not a member of ‘String’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#String for information about the String type. -`); +`)); throws (() => f (x => x) (['a', 'b', 'c'])) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value f :: (String -> Number) -> Array String -> Array Number ^^^^^^ @@ -2549,7 +2459,7 @@ f :: (String -> Number) -> Array String -> Array Number The value at position 1 is not a member of ‘Number’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for information about the Number type. -`); +`)); // map :: (a -> b) -> Array a -> Array b const map = @@ -2567,8 +2477,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for in eq (map (s => s.length) (['foo', 'bar'])) ([3, 3]); throws (() => map (s => s.length) (['foo', 'bar', 'baz', 'quux'])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation map :: (a -> b) -> Array a -> Array b ^ ^ @@ -2585,11 +2494,10 @@ map :: (a -> b) -> Array a -> Array b "quux" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => map (s => s === 'baz' ? null : s.length) (['foo', 'bar', 'baz'])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation map :: (a -> b) -> Array a -> Array b ^ @@ -2600,7 +2508,7 @@ map :: (a -> b) -> Array a -> Array b null :: Null Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); // reduce_ :: ((a, b) -> a) -> a -> Array b -> a const reduce_ = @@ -2612,8 +2520,7 @@ Since there is no type of which all the above values are members, the type-varia eq (reduce_ ((x, y) => x + y) (0) ([1, 2, 3, 4, 5, 6])) (21); throws (() => reduce_ (null)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value reduce_ :: ((a, b) -> a) -> a -> Array b -> a ^^^^^^^^^^^^^ @@ -2622,7 +2529,7 @@ reduce_ :: ((a, b) -> a) -> a -> Array b -> a 1) null :: Null The value at position 1 is not a member of ‘(a, b) -> a’. -`); +`)); // unfoldr :: (b -> Maybe (Array2 a b)) -> b -> Array a const unfoldr = @@ -2645,8 +2552,7 @@ The value at position 1 is not a member of ‘(a, b) -> a’. eq (unfoldr (h) (1)) ([1, 2, 3, 4]); throws (() => unfoldr (null)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value unfoldr :: (b -> Maybe (Array2 a b)) -> b -> Array a ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2655,7 +2561,7 @@ unfoldr :: (b -> Maybe (Array2 a b)) -> b -> Array a 1) null :: Null The value at position 1 is not a member of ‘b -> Maybe (Array2 a b)’. -`); +`)); // T :: a -> (a -> b) -> b const T = @@ -2665,15 +2571,14 @@ The value at position 1 is not a member of ‘b -> Maybe (Array2 a b)’. (x => f => f (/* x */)); throws (() => T (100) (Math.sqrt)) - (TypeError) - (`‘T’ applied ‘a -> b’ to the wrong number of arguments + (new TypeError (`‘T’ applied ‘a -> b’ to the wrong number of arguments T :: a -> (a -> b) -> b ^ 1 Expected one argument but received zero arguments. -`); +`)); }); test ('supports type-class constraints', () => { @@ -2693,8 +2598,7 @@ Expected one argument but received zero arguments. eq (alt (Just (3)) (Just (4))) (Just (3)); throws (() => alt (Left (1))) - (TypeError) - (`Type-class constraint violation + (new TypeError (`Type-class constraint violation alt :: Alternative a => a -> a -> a ^^^^^^^^^^^^^ ^ @@ -2705,7 +2609,7 @@ alt :: Alternative a => a -> a -> a ‘alt’ requires ‘a’ to satisfy the Alternative type-class constraint; the value at position 1 does not. See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Alternative for information about the sanctuary-type-classes/Alternative type class. -`); +`)); // concat :: Semigroup a => a -> a -> a const concat = @@ -2718,8 +2622,7 @@ See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Al eq (concat ('abc') ('def')) ('abcdef'); throws (() => concat (/x/)) - (TypeError) - (`Type-class constraint violation + (new TypeError (`Type-class constraint violation concat :: Semigroup a => a -> a -> a ^^^^^^^^^^^ ^ @@ -2730,11 +2633,10 @@ concat :: Semigroup a => a -> a -> a ‘concat’ requires ‘a’ to satisfy the Semigroup type-class constraint; the value at position 1 does not. See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Semigroup for information about the sanctuary-type-classes/Semigroup type class. -`); +`)); throws (() => concat ([]) ('')) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation concat :: Semigroup a => a -> a -> a ^ ^ @@ -2745,11 +2647,10 @@ concat :: Semigroup a => a -> a -> a 2) "" :: String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => concat ('') ([])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation concat :: Semigroup a => a -> a -> a ^ ^ @@ -2760,7 +2661,7 @@ concat :: Semigroup a => a -> a -> a 2) [] :: Array b Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); // filter :: (Alternative m, Monad m) => (a -> Boolean) -> m a -> m a const filter = @@ -2777,8 +2678,7 @@ Since there is no type of which all the above values are members, the type-varia eq (filter (even) (Just (4))) (Just (4)); throws (() => filter (even) (Right (42))) - (TypeError) - (`Type-class constraint violation + (new TypeError (`Type-class constraint violation filter :: (Alternative m, Monad m) => (a -> Boolean) -> m a -> m a ^^^^^^^^^^^^^ ^^^ @@ -2789,7 +2689,7 @@ filter :: (Alternative m, Monad m) => (a -> Boolean) -> m a -> m a ‘filter’ requires ‘m’ to satisfy the Alternative type-class constraint; the value at position 1 does not. See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Alternative for information about the sanctuary-type-classes/Alternative type class. -`); +`)); // concatMaybes :: Semigroup a => Maybe a -> Maybe a -> Maybe a const concatMaybes = @@ -2799,8 +2699,7 @@ See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Al (m => n => Just (/xxx/)); throws (() => concatMaybes (Just (/xxx/))) - (TypeError) - (`Type-class constraint violation + (new TypeError (`Type-class constraint violation concatMaybes :: Semigroup a => Maybe a -> Maybe a -> Maybe a ^^^^^^^^^^^ ^ @@ -2811,11 +2710,10 @@ concatMaybes :: Semigroup a => Maybe a -> Maybe a -> Maybe a ‘concatMaybes’ requires ‘a’ to satisfy the Semigroup type-class constraint; the value at position 1 does not. See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Semigroup for information about the sanctuary-type-classes/Semigroup type class. -`); +`)); throws (() => concatMaybes (Just ('abc')) (Just (/xxx/))) - (TypeError) - (`Type-class constraint violation + (new TypeError (`Type-class constraint violation concatMaybes :: Semigroup a => Maybe a -> Maybe a -> Maybe a ^^^^^^^^^^^ ^ @@ -2826,11 +2724,10 @@ concatMaybes :: Semigroup a => Maybe a -> Maybe a -> Maybe a ‘concatMaybes’ requires ‘a’ to satisfy the Semigroup type-class constraint; the value at position 1 does not. See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Semigroup for information about the sanctuary-type-classes/Semigroup type class. -`); +`)); throws (() => concatMaybes (Just ('abc')) (Just ('def'))) - (TypeError) - (`Type-class constraint violation + (new TypeError (`Type-class constraint violation concatMaybes :: Semigroup a => Maybe a -> Maybe a -> Maybe a ^^^^^^^^^^^ ^ @@ -2841,7 +2738,7 @@ concatMaybes :: Semigroup a => Maybe a -> Maybe a -> Maybe a ‘concatMaybes’ requires ‘a’ to satisfy the Semigroup type-class constraint; the value at position 1 does not. See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Semigroup for information about the sanctuary-type-classes/Semigroup type class. -`); +`)); // sillyConst :: (Alternative a, Semigroup b) => a -> b -> a const sillyConst = @@ -2853,8 +2750,7 @@ See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Se eq (sillyConst (Just (42)) ([1, 2, 3])) (Just (42)); throws (() => sillyConst (true)) - (TypeError) - (`Type-class constraint violation + (new TypeError (`Type-class constraint violation sillyConst :: (Alternative a, Semigroup b) => a -> b -> a ^^^^^^^^^^^^^ ^ @@ -2865,7 +2761,7 @@ sillyConst :: (Alternative a, Semigroup b) => a -> b -> a ‘sillyConst’ requires ‘a’ to satisfy the Alternative type-class constraint; the value at position 1 does not. See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Alternative for information about the sanctuary-type-classes/Alternative type class. -`); +`)); }); test ('supports unary type variables', () => { @@ -2889,8 +2785,7 @@ See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Al xs['fantasy-land/map'] = xs.map; throws (() => map (Math.sqrt) (xs)) - (TypeError) - (`‘map’ applied ‘a -> b’ to the wrong number of arguments + (new TypeError (`‘map’ applied ‘a -> b’ to the wrong number of arguments map :: Functor f => (a -> b) -> f a -> f b ^ @@ -2901,7 +2796,7 @@ Expected one argument but received three arguments: - 1 - 0 - [1, 4, 9, "fantasy-land/map": function map() { [native code] }] -`); +`)); // sum :: Foldable f => f FiniteNumber -> FiniteNumber const sum = @@ -2917,8 +2812,7 @@ Expected one argument but received three arguments: eq (sum (Right (42))) (42); throws (() => sum (42)) - (TypeError) - (`Type-class constraint violation + (new TypeError (`Type-class constraint violation sum :: Foldable f => f FiniteNumber -> FiniteNumber ^^^^^^^^^^ ^^^^^^^^^^^^^^ @@ -2929,11 +2823,10 @@ sum :: Foldable f => f FiniteNumber -> FiniteNumber ‘sum’ requires ‘f’ to satisfy the Foldable type-class constraint; the value at position 1 does not. See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Foldable for information about the sanctuary-type-classes/Foldable type class. -`); +`)); throws (() => sum (Just (Infinity))) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value sum :: Foldable f => f FiniteNumber -> FiniteNumber ^^^^^^^^^^^^ @@ -2944,7 +2837,7 @@ sum :: Foldable f => f FiniteNumber -> FiniteNumber The value at position 1 is not a member of ‘FiniteNumber’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#FiniteNumber for information about the sanctuary-def/FiniteNumber type. -`); +`)); // sort :: (Ord a, Applicative f, Foldable f, Monoid (f a)) => f a -> f a const sort = @@ -2968,8 +2861,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#FiniteNumber eq (sort (['foo', 'bar', 'baz'])) (['bar', 'baz', 'foo']); throws (() => sort (['foo', true, 42])) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation sort :: (Ord a, Applicative f, Foldable f, Monoid f) => f a -> f a ^ @@ -2980,11 +2872,10 @@ sort :: (Ord a, Applicative f, Foldable f, Monoid f) => f a -> f a 42 :: Number Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); throws (() => sort ([Math.sin, Math.cos])) - (TypeError) - (`Type-class constraint violation + (new TypeError (`Type-class constraint violation sort :: (Ord a, Applicative f, Foldable f, Monoid f) => f a -> f a ^^^^^ ^ @@ -2995,7 +2886,7 @@ sort :: (Ord a, Applicative f, Foldable f, Monoid f) => f a -> f a ‘sort’ requires ‘a’ to satisfy the Ord type-class constraint; the value at position 1 does not. See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Ord for information about the sanctuary-type-classes/Ord type class. -`); +`)); }); test ('supports binary type variables', () => { @@ -3016,8 +2907,7 @@ See https://github.com/sanctuary-js/sanctuary-type-classes/tree/v${Z$version}#Or eq (bimap (s => s.length) (Math.sqrt) (Pair ('Sanctuary') (25))) (Pair (9) (5)); throws (() => bimap (xs => xs.length) (Math.sqrt) (Pair (['foo', true, 42]) (null))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation bimap :: Bifunctor f => (a -> b) -> (c -> d) -> f a c -> f b d ^ @@ -3026,7 +2916,7 @@ bimap :: Bifunctor f => (a -> b) -> (c -> d) -> f a c -> f b d 1) ["foo", true, 42] :: Array ??? Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); // chain :: Chain m => (a -> m b) -> m a -> m b const chain = @@ -3036,8 +2926,7 @@ Since there is no type of which all the above values are members, the type-varia (curry2 (Z.chain)); throws (() => chain (Left) (Just ('x'))) - (TypeError) - (`Type-variable constraint violation + (new TypeError (`Type-variable constraint violation chain :: Chain m => (a -> m b) -> m a -> m b ^^^ ^^^ @@ -3048,7 +2937,7 @@ chain :: Chain m => (a -> m b) -> m a -> m b 2) Just("x") :: Maybe String Since there is no type of which all the above values are members, the type-variable constraint has been violated. -`); +`)); }); test ('only determines actual types when necessary', () => { @@ -3091,8 +2980,7 @@ Since there is no type of which all the above values are members, the type-varia (curry2 (Z.map)); throws (() => map (Right (Right (Right (Right (0)))))) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value map :: Functor f => (a -> b) -> f a -> f b ^^^^^^^^ @@ -3101,7 +2989,7 @@ map :: Functor f => (a -> b) -> f a -> f b 1) Right(Right(Right(Right(0)))) :: Either c (Either d (Either e (Either g Number))) The value at position 1 is not a member of ‘a -> b’. -`); +`)); }); }); @@ -3171,8 +3059,7 @@ suite ('UnaryType', () => { test ('returns a type constructor which type checks its arguments', () => { throws (() => Maybe ({x: $.Number, y: $.Number})) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value Maybe :: Type -> Type ^^^^ @@ -3183,7 +3070,7 @@ Maybe :: Type -> Type The value at position 1 is not a member of ‘Type’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Type for information about the Type type. -`); +`)); }); }); @@ -3198,8 +3085,7 @@ suite ('BinaryType', () => { test ('returns a type constructor which type checks its arguments', () => { throws (() => Either ($.Number) ({x: $.Number, y: $.Number})) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value Either :: Type -> Type -> Type ^^^^ @@ -3210,7 +3096,7 @@ Either :: Type -> Type -> Type The value at position 1 is not a member of ‘Type’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Type for information about the Type type. -`); +`)); }); }); @@ -3242,8 +3128,7 @@ suite ('UnaryTypeVariable', () => { eq (String (f (a))) ('(f a)'); throws (() => f (Number)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value f :: Type -> Type ^^^^ @@ -3254,7 +3139,7 @@ f :: Type -> Type The value at position 1 is not a member of ‘Type’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Type for information about the Type type. -`); +`)); }); }); @@ -3276,8 +3161,7 @@ suite ('BinaryTypeVariable', () => { eq (String (p (a) (b))) ('(p a b)'); throws (() => p (Number)) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value p :: Type -> Type -> Type ^^^^ @@ -3288,7 +3172,7 @@ p :: Type -> Type -> Type The value at position 1 is not a member of ‘Type’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Type for information about the Type type. -`); +`)); }); }); @@ -3315,8 +3199,7 @@ suite ('Thunk', () => { eq (why (() => 42)) (42); throws (() => why (() => 'Who knows?')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value why :: (() -> Integer) -> Integer ^^^^^^^ @@ -3327,7 +3210,7 @@ why :: (() -> Integer) -> Integer The value at position 1 is not a member of ‘Integer’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Integer for information about the sanctuary-def/Integer type. -`); +`)); }); }); @@ -3358,8 +3241,7 @@ suite ('Predicate', () => { eq (abs (-1)) (1); throws (() => when (x => x) (x => x) ('foo')) - (TypeError) - (`Invalid value + (new TypeError (`Invalid value when :: (a -> Boolean) -> (a -> a) -> a -> a ^^^^^^^ @@ -3370,7 +3252,7 @@ when :: (a -> Boolean) -> (a -> a) -> a -> a The value at position 1 is not a member of ‘Boolean’. See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Boolean for information about the Boolean type. -`); +`)); }); });