Skip to content

Commit

Permalink
documentation: remove ‘concat ({}) ({})’ to avoid confusion
Browse files Browse the repository at this point in the history
Although this naive concat function cannot operate on objects, Z.concat
and S.concat can do so. ‘concat ({}) ({})’ is thus a confusing example:
it is a logical operation but it is not supported due to a shortcoming.
‘concat (null) (null)’ is clearer.
  • Loading branch information
davidchambers committed May 13, 2018
1 parent 83f1148 commit dbf7bbf
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1975,14 +1975,10 @@
//. The type of `_concat` is misleading: it suggests that it can operate on
//. any two values of *any* one type. In fact there's an implicit constraint,
//. since the type must support concatenation (in [mathematical][semigroup]
//. terms, the type must have a [semigroup][FL:Semigroup]). The run-time type
//. errors that result when this constraint is violated are not particularly
//. descriptive:
//. terms, the type must have a [semigroup][FL:Semigroup]). Violating this
//. implicit constraint results in a run-time error in the implementation:
//.
//. ```javascript
//. _concat ({}) ({});
//. // ! TypeError: undefined is not a function
//.
//. _concat (null) (null);
//. // ! TypeError: Cannot read property 'concat' of null
//. ```
Expand Down Expand Up @@ -2012,19 +2008,6 @@
//. concat ([1, 2]) ([3, 4]);
//. // => [1, 2, 3, 4]
//.
//. concat ({}) ({});
//. // ! TypeError: Type-class constraint violation
//. //
//. // concat :: Semigroup a => a -> a -> a
//. // ^^^^^^^^^^^ ^
//. // 1
//. //
//. // 1) {} :: Object, StrMap ???
//. //
//. // ‘concat’ requires ‘a’ to satisfy the Semigroup type-class constraint; the value at position 1 does not.
//. //
//. // See http://example.com/my-package#Semigroup for information about the my-package/Semigroup type class.
//.
//. concat (null) (null);
//. // ! TypeError: Type-class constraint violation
//. //
Expand Down

0 comments on commit dbf7bbf

Please sign in to comment.