Skip to content

Commit

Permalink
Merge pull request #267 from sanctuary-js/davidchambers/env
Browse files Browse the repository at this point in the history
env: add ‘Array2 ??? ???’, ‘Type’, and ‘TypeClass’
  • Loading branch information
davidchambers committed Apr 25, 2019
2 parents 636c58b + d533394 commit 48192a3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@
//. - <code>[AnyFunction](#AnyFunction)</code>
//. - <code>[Arguments](#Arguments)</code>
//. - <code>[Array](#Array) ([Unknown][])</code>
//. - <code>[Array2](#Array2) ([Unknown][]) ([Unknown][])</code>
//. - <code>[Boolean](#Boolean)</code>
//. - <code>[Date](#Date)</code>
//. - <code>[Descending](#Descending) ([Unknown][])</code>
Expand All @@ -1027,11 +1028,14 @@
//. - <code>[StrMap](#StrMap) ([Unknown][])</code>
//. - <code>[String](#String)</code>
//. - <code>[Symbol](#Symbol)</code>
//. - <code>[Type](#Type)</code>
//. - <code>[TypeClass](#TypeClass)</code>
//. - <code>[Undefined](#Undefined)</code>
var env = [
AnyFunction,
Arguments,
Array_ (Unknown),
Array2 (Unknown) (Unknown),
Boolean_,
Date_,
Descending (Unknown),
Expand All @@ -1049,6 +1053,8 @@
StrMap (Unknown),
String_,
Symbol_,
Type,
TypeClass,
Undefined
];

Expand Down
40 changes: 20 additions & 20 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ a01 :: a -> Array a -> a
^ ^
1 2
1) [1, 2] :: Array Number
1) [1, 2] :: Array Number, Array2 Number Number
2) 1 :: Number
2 :: Number
Expand All @@ -576,10 +576,10 @@ a01 :: a -> Array a -> a
^ ^
1 2
1) [1, 2] :: Array Number
1) [1, 2] :: Array Number, Array2 Number Number
2) ["a", "b"] :: Array String
["c", "d"] :: Array String
2) ["a", "b"] :: Array String, Array2 String String
["c", "d"] :: Array String, Array2 String String
Since there is no type of which all the above values are members, the type-variable constraint has been violated.
`));
Expand All @@ -591,10 +591,10 @@ a01 :: a -> Array a -> a
^ ^
1 2
1) [[1, 2], [3, 4]] :: Array (Array Number)
1) [[1, 2], [3, 4]] :: Array (Array Number), Array (Array2 Number Number), Array2 (Array Number) (Array Number), Array2 (Array Number) (Array2 Number Number), Array2 (Array2 Number Number) (Array Number), Array2 (Array2 Number Number) (Array2 Number Number)
2) [1, 2] :: Array Number
[3, 4] :: Array Number
2) [1, 2] :: Array Number, Array2 Number Number
[3, 4] :: Array Number, Array2 Number Number
Since there is no type of which all the above values are members, the type-variable constraint has been violated.
`));
Expand All @@ -606,7 +606,7 @@ a02 :: a -> Array (Array a) -> a
^ ^
1 2
1) [1, 2] :: Array Number
1) [1, 2] :: Array Number, Array2 Number Number
2) 1 :: Number
2 :: Number
Expand Down Expand Up @@ -930,16 +930,16 @@ The value at position 1 is not a member of ‘TimeUnit’.
eq (id (42)) (42);
eq (id (-42)) (-42);

eq (id (['foo', true])) (['foo', true]);
eq (id (['foo', true, 42])) (['foo', true, 42]);

throws (() => { id (['foo', false]); })
throws (() => { id (['foo', false, 42]); })
(new TypeError (`Type-variable constraint violation
id :: a -> a
^
1
1) ["foo", false] :: Array ???
1) ["foo", false, 42] :: Array ???
Since there is no type of which all the above values are members, the type-variable constraint has been violated.
`));
Expand Down Expand Up @@ -2100,14 +2100,14 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Number for in
eq (testBinaryType (Left ('XXX'))) (Left ('XXX'));
eq (testBinaryType (Right ({x: 1, y: 2, z: 3}))) (Right ({x: 1, y: 2, z: 3}));

throws (() => { testBinaryType (Right ({x: ['foo', false]})); })
throws (() => { testBinaryType (Right ({x: ['foo', false, 42]})); })
(new TypeError (`Type-variable constraint violation
testBinaryType :: Either a (StrMap b) -> Either a (StrMap b)
^
1
1) ["foo", false] :: Array ???
1) ["foo", false, 42] :: Array ???
Since there is no type of which all the above values are members, the type-variable constraint has been violated.
`));
Expand Down Expand Up @@ -2227,14 +2227,14 @@ aa :: a -> a -> Pair a a
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]); })
throws (() => { aa ([Left ('XXX'), false, 42]); })
(new TypeError (`Type-variable constraint violation
aa :: a -> a -> Pair a a
^
1
1) [Left ("XXX"), 42] :: Array ???
1) [Left ("XXX"), false, 42] :: Array ???
Since there is no type of which all the above values are members, the type-variable constraint has been violated.
`));
Expand Down Expand Up @@ -2279,7 +2279,7 @@ fst :: Pair a b -> a
^^^^^^^^
1
1) ["XXX", 42] :: Array ???
1) ["XXX", 42] :: Array ???, Array2 String Number
The value at position 1 is not a member of ‘Pair a b’.
Expand Down Expand Up @@ -2543,7 +2543,7 @@ concat :: Array a -> Array a -> Array a
1
1) [1, 2, 3] :: Array Number
[Left ("XXX"), Right (42)] :: Array (Either String Number)
[Left ("XXX"), Right (42)] :: Array (Either String Number), Array2 (Either String b) (Either c Number)
Since there is no type of which all the above values are members, the type-variable constraint has been violated.
`));
Expand All @@ -2556,7 +2556,7 @@ concat :: Array a -> Array a -> Array a
1
1) [1, 2, 3] :: Array Number
[Right (42), Left ("XXX")] :: Array (Either String Number)
[Right (42), Left ("XXX")] :: Array (Either String Number), Array2 (Either b Number) (Either String c)
Since there is no type of which all the above values are members, the type-variable constraint has been violated.
`));
Expand Down Expand Up @@ -3446,7 +3446,7 @@ MyUnaryType :: Type -> Type
^^^^
1
1) {"x": Number, "y": Number} :: Object, StrMap ???
1) {"x": Number, "y": Number} :: Object, StrMap Type
The value at position 1 is not a member of ‘Type’.
Expand Down Expand Up @@ -3498,7 +3498,7 @@ MyBinaryType :: Type -> Type -> Type
^^^^
1
1) {"x": Number, "y": Number} :: Object, StrMap ???
1) {"x": Number, "y": Number} :: Object, StrMap Type
The value at position 1 is not a member of ‘Type’.
Expand Down

0 comments on commit 48192a3

Please sign in to comment.