diff --git a/README.md b/README.md
index 3ffc85de..e3e2583f 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ If `words` is `[]` we'll get a familiar error at run-time:
Sanctuary gives us a fighting chance of avoiding such errors. We might
write:
- R.map(R.toUpper, S.head(words))
+ R.map(S.toUpper, S.head(words))
## Types
@@ -101,14 +101,22 @@ silent failures due to type coercion (at worst). For example:
```javascript
S.inc('XXX');
-// ! TypeError: ‘inc’ expected a value of type FiniteNumber as its first argument; received "XXX"
+// ! TypeError: Invalid value
+//
+// inc :: FiniteNumber -> FiniteNumber
+// ^^^^^^^^^^^^
+// 1
+//
+// 1) "XXX" :: String
+//
+// The value at position 1 is not a member of ‘FiniteNumber’.
```
Compare this to the behaviour of Ramda's unchecked equivalent:
```javascript
R.inc('XXX');
-// => '1XXX'
+// => NaN
```
There is a performance cost to run-time type checking. One may wish to
@@ -134,7 +142,7 @@ const S = process.env.NODE_ENV === 'production' ?
### Classify
-
+
Takes a value, `x`, of any type and returns its type identifier. If
`x` has a `'@@type'` property whose value is a string, `x['@@type']`
@@ -153,7 +161,7 @@ is defined.
'Array'
```
-
+
Takes a [type representative](#type-representatives) and a value of
any type and returns `true` if the given value is of the specified
@@ -172,7 +180,7 @@ false
### Combinator
-
+
The I combinator. Returns its argument. Equivalent to Haskell's `id`
function.
@@ -182,7 +190,7 @@ function.
'foo'
```
-
+
The K combinator. Takes two values and returns the first. Equivalent to
Haskell's `const` function.
@@ -195,20 +203,20 @@ Haskell's `const` function.
[42, 42, 42, 42, 42]
```
-
+
The A combinator. Takes a function and a value, and returns the result of
applying the function to the value. Equivalent to Haskell's `($)` function.
```javascript
-> S.A(R.inc, 1)
+> S.A(S.inc, 1)
2
-> R.map(S.A(R.__, 100), [R.inc, Math.sqrt])
+> R.map(S.A(R.__, 100), [S.inc, Math.sqrt])
[101, 10]
```
-
+
The C combinator. Takes a curried binary function and two values, and
returns the result of applying the function to the values in reverse.
@@ -226,7 +234,7 @@ functions.
[3, 4, 2]
```
-
+
The B combinator. Takes two functions and a value, and returns the result
of applying the first function to the result of applying the second to the
@@ -237,7 +245,7 @@ value. Equivalent to [`compose`](#compose) and Haskell's `(.)` function.
10
```
-
+
The S combinator. Takes a curried binary function, a unary function,
and a value, and returns the result of applying the binary function to:
@@ -246,13 +254,13 @@ and a value, and returns the result of applying the binary function to:
- the result of applying the unary function to the value.
```javascript
-> S.S(R.add, Math.sqrt, 100)
+> S.S(S.add, Math.sqrt, 100)
110
```
### Function
-
+
Takes a binary function and two values and returns the result of
applying the function - with its argument order reversed - to the
@@ -266,7 +274,7 @@ See also [`C`](#C).
[1, 4, 9, 16, 25]
```
-
+
Promotes a unary function to a function which operates on a [Functor][].
@@ -278,16 +286,16 @@ Just(3)
Nothing()
```
-
+
Promotes a binary function to a function which operates on two
[Apply][]s.
```javascript
-> S.lift2(R.add, S.Just(2), S.Just(3))
+> S.lift2(S.add, S.Just(2), S.Just(3))
Just(5)
-> S.lift2(R.add, S.Just(2), S.Nothing())
+> S.lift2(S.add, S.Just(2), S.Nothing())
Nothing()
> S.lift2(S.and, S.Just(true), S.Just(true))
@@ -297,7 +305,7 @@ Just(true)
Just(false)
```
-
+
Promotes a ternary function to a function which operates on three
[Apply][]s.
@@ -312,7 +320,7 @@ Nothing()
### Composition
-
+
Takes two functions assumed to be unary and a value of any type,
and returns the result of applying the first function to the result
@@ -328,7 +336,7 @@ See also [`B`](#B) and [`pipe`](#pipe).
10
```
-
+
Takes a list of functions assumed to be unary and a value of any type,
and returns the result of applying the sequence of transformations to
@@ -344,7 +352,7 @@ See also [`meld`](#meld).
9
```
-
+
Takes a list of non-nullary functions and returns a curried function
whose arity is one greater than the sum of the arities of the given
@@ -379,15 +387,15 @@ either a Just whose value is of type `a` or a Nothing (with no value).
The Maybe type satisfies the [Monoid][], [Monad][], [Traversable][],
and [Extend][] specifications.
-
+
A [`UnaryType`][UnaryType] for use with [sanctuary-def][].
-
+
The [type representative](#type-representatives) for the Maybe type.
-
+
Returns a Nothing.
@@ -396,7 +404,7 @@ Returns a Nothing.
Nothing()
```
-
+
Takes a value of any type and returns a Just with the given value.
@@ -405,11 +413,11 @@ Takes a value of any type and returns a Just with the given value.
Just(42)
```
-
+
Maybe type identifier, `'sanctuary/Maybe'`.
-
+
`true` if `this` is a Nothing; `false` if `this` is a Just.
@@ -421,7 +429,7 @@ true
false
```
-
+
`true` if `this` is a Just; `false` if `this` is a Nothing.
@@ -433,7 +441,7 @@ true
false
```
-
+
Takes a value of type `Maybe a` and returns a Nothing unless `this`
is a Just *and* the argument is a Just, in which case it returns a
@@ -451,7 +459,7 @@ Nothing()
Just(43)
```
-
+
Takes a function and returns `this` if `this` is a Nothing; otherwise
it returns the result of applying the function to this Just's value.
@@ -467,7 +475,7 @@ Nothing()
Just(12.34)
```
-
+
Returns the result of concatenating two Maybe values of the same type.
`a` must have a [Semigroup][] (indicated by the presence of a `concat`
@@ -496,7 +504,7 @@ Just([1, 2, 3])
Just([1, 2, 3])
```
-
+
Returns a Nothing.
@@ -505,7 +513,7 @@ Returns a Nothing.
Nothing()
```
-
+
Takes a value of any type and returns `true` if:
@@ -531,7 +539,7 @@ false
false
```
-
+
Takes a function and returns `this` if `this` is a Nothing; otherwise
it returns a Just whose value is the result of applying the function to
@@ -545,7 +553,7 @@ Nothing()
Just(43)
```
-
+
Takes a predicate and returns `this` if `this` is a Just whose value
satisfies the predicate; Nothing otherwise.
@@ -558,7 +566,7 @@ Just(42)
Nothing()
```
-
+
Takes a function and returns `this` if `this` is a Nothing; otherwise
it returns a Just whose value is the result of applying the function to
@@ -572,7 +580,7 @@ Nothing()
Just(6)
```
-
+
Takes a value of any type and returns a Just with the given value.
@@ -581,7 +589,7 @@ Takes a value of any type and returns a Just with the given value.
Just(42)
```
-
+
Takes a function and an initial value of any type, and returns:
@@ -598,7 +606,7 @@ Takes a function and an initial value of any type, and returns:
15
```
-
+
Evaluates an applicative action contained within the Maybe, resulting in:
@@ -614,7 +622,7 @@ Right(Nothing())
Right(Just(42))
```
-
+
Returns `false` if `this` is a Nothing; `true` if `this` is a Just.
@@ -626,7 +634,7 @@ false
true
```
-
+
Returns the string representation of the Maybe.
@@ -638,7 +646,7 @@ Returns the string representation of the Maybe.
'Just([1, 2, 3])'
```
-
+
Returns the string representation of the Maybe. This method is used by
`util.inspect` and the REPL to format a Maybe for display.
@@ -653,7 +661,7 @@ See also [`Maybe#toString`](#Maybe.prototype.toString).
'Just([1, 2, 3])'
```
-
+
Returns a Nothing. Though this is a constructor function the `new`
keyword needn't be used.
@@ -663,7 +671,7 @@ keyword needn't be used.
Nothing()
```
-
+
Takes a value of any type and returns a Just with the given value.
Though this is a constructor function the `new` keyword needn't be
@@ -674,7 +682,7 @@ used.
Just(42)
```
-
+
Returns `true` if the given Maybe is a Nothing; `false` if it is a Just.
@@ -686,7 +694,7 @@ true
false
```
-
+
Returns `true` if the given Maybe is a Just; `false` if it is a Nothing.
@@ -698,7 +706,7 @@ true
false
```
-
+
Takes a default value and a Maybe, and returns the Maybe's value
if the Maybe is a Just; the default value otherwise.
@@ -711,7 +719,7 @@ if the Maybe is a Just; the default value otherwise.
0
```
-
+
Takes a value and returns Nothing if the value is null or undefined;
Just the value otherwise.
@@ -724,7 +732,7 @@ Nothing()
Just(42)
```
-
+
Takes a value of any type, a function, and a Maybe. If the Maybe is
a Just, the return value is the result of applying the function to
@@ -738,7 +746,7 @@ the Just's value. Otherwise, the first argument is returned.
0
```
-
+
Takes a list of Maybes and returns a list containing each Just's value.
@@ -747,7 +755,7 @@ Takes a list of Maybes and returns a list containing each Just's value.
['foo', 'baz']
```
-
+
Takes a function and a list, applies the function to each element of
the list, and returns a list of "successful" results. If the result of
@@ -762,7 +770,7 @@ In general terms, `mapMaybe` filters a list while mapping over it.
[1, 4]
```
-
+
Takes a unary function `f` which may throw and a value `x` of any type,
and applies `f` to `x` inside a `try` block. If an exception is caught,
@@ -779,11 +787,11 @@ Just(2)
Nothing()
```
-
+
Binary version of [`encase`](#encase).
-
+
Ternary version of [`encase`](#encase).
@@ -796,15 +804,15 @@ value is of type `b`.
The Either type satisfies the [Semigroup][], [Monad][], and [Extend][]
specifications.
-
+
A [`BinaryType`][BinaryType] for use with [sanctuary-def][].
-
+
The [type representative](#type-representatives) for the Either type.
-
+
Takes a value of any type and returns a Right with the given value.
@@ -813,11 +821,11 @@ Takes a value of any type and returns a Right with the given value.
Right(42)
```
-
+
Either type identifier, `'sanctuary/Either'`.
-
+
`true` if `this` is a Left; `false` if `this` is a Right.
@@ -829,7 +837,7 @@ true
false
```
-
+
`true` if `this` is a Right; `false` if `this` is a Left.
@@ -841,7 +849,7 @@ true
false
```
-
+
Takes a value of type `Either a b` and returns a Left unless `this`
is a Right *and* the argument is a Right, in which case it returns
@@ -859,7 +867,7 @@ Left('Cannot divide by zero')
Right(43)
```
-
+
Takes a function and returns `this` if `this` is a Left; otherwise
it returns the result of applying the function to this Right's value.
@@ -880,7 +888,7 @@ Left('Cannot represent square root of negative number')
Right(5)
```
-
+
Returns the result of concatenating two Either values of the same type.
`a` must have a [Semigroup][] (indicated by the presence of a `concat`
@@ -910,7 +918,7 @@ Right([1, 2, 3])
Right([1, 2, 3])
```
-
+
Takes a value of any type and returns `true` if:
@@ -931,7 +939,7 @@ false
false
```
-
+
Takes a function and returns `this` if `this` is a Left; otherwise it
returns a Right whose value is the result of applying the function to
@@ -945,7 +953,7 @@ Left('Cannot divide by zero')
Right(43)
```
-
+
Takes a function and returns `this` if `this` is a Left; otherwise it
returns a Right whose value is the result of applying the function to
@@ -959,7 +967,7 @@ Left('Cannot divide by zero')
Right(6)
```
-
+
Takes a value of any type and returns a Right with the given value.
@@ -968,7 +976,7 @@ Takes a value of any type and returns a Right with the given value.
Right(42)
```
-
+
Returns `false` if `this` is a Left; `true` if `this` is a Right.
@@ -980,7 +988,7 @@ false
true
```
-
+
Returns the string representation of the Either.
@@ -992,7 +1000,7 @@ Returns the string representation of the Either.
'Right([1, 2, 3])'
```
-
+
Returns the string representation of the Either. This method is used by
`util.inspect` and the REPL to format a Either for display.
@@ -1007,7 +1015,7 @@ See also [`Either#toString`](#Either.prototype.toString).
'Right([1, 2, 3])'
```
-
+
Takes a value of any type and returns a Left with the given value.
Though this is a constructor function the `new` keyword needn't be
@@ -1018,7 +1026,7 @@ used.
Left('Cannot divide by zero')
```
-
+
Takes a value of any type and returns a Right with the given value.
Though this is a constructor function the `new` keyword needn't be
@@ -1029,7 +1037,7 @@ used.
Right(42)
```
-
+
Returns `true` if the given Either is a Left; `false` if it is a Right.
@@ -1041,7 +1049,7 @@ true
false
```
-
+
Returns `true` if the given Either is a Right; `false` if it is a Left.
@@ -1053,7 +1061,7 @@ true
false
```
-
+
Takes two functions and an Either, and returns the result of
applying the first function to the Left's value, if the Either
@@ -1068,7 +1076,7 @@ Right's value, if the Either is a Right.
'42'
```
-
+
Takes a list of Eithers and returns a list containing each Left's value.
@@ -1079,7 +1087,7 @@ See also [`rights`](#rights).
['foo', 'bar']
```
-
+
Takes a list of Eithers and returns a list containing each Right's value.
@@ -1090,7 +1098,7 @@ See also [`lefts`](#lefts).
[20, 10]
```
-
+
Takes two unary functions, `f` and `g`, the second of which may throw,
and a value `x` of any type. Applies `g` to `x` inside a `try` block.
@@ -1111,15 +1119,15 @@ Left(new SyntaxError('Unexpected end of input'))
Left('Unexpected end of input')
```
-
+
Binary version of [`encaseEither`](#encaseEither).
-
+
Ternary version of [`encaseEither`](#encaseEither).
-
+
Takes a value of any type and a Maybe, and returns an Either.
If the second argument is a Nothing, a Left containing the first
@@ -1136,7 +1144,7 @@ Right(42)
### Alternative
-
+
Takes two values of the same type and returns the second value
if the first is "true"; the first value otherwise. An array is
@@ -1152,7 +1160,7 @@ Just(2)
Nothing()
```
-
+
Takes two values of the same type and returns the first value if it
is "true"; the second value otherwise. An array is considered "true"
@@ -1167,7 +1175,7 @@ Just(1)
Just(3)
```
-
+
Takes two values of the same type and returns the "true" value
if one value is "true" and the other is "false"; otherwise it
@@ -1186,7 +1194,7 @@ Nothing()
### Logic
-
+
Takes a Boolean and returns the negation of that value
(`false` for `true`; `true` for `false`).
@@ -1199,7 +1207,7 @@ false
true
```
-
+
Takes a unary predicate, a unary "if" function, a unary "else"
function, and a value of any type, and returns the result of
@@ -1215,7 +1223,7 @@ value otherwise.
4
```
-
+
Takes an array of unary predicates and a value of any type
and returns `true` if all the predicates pass; `false` otherwise.
@@ -1230,7 +1238,7 @@ true
false
```
-
+
Takes an array of unary predicates and a value of any type
and returns `true` if any of the predicates pass; `false` otherwise.
@@ -1247,7 +1255,7 @@ false
### List
-
+
Returns Just a list containing the elements from the supplied list
from a beginning index (inclusive) to an end index (exclusive).
@@ -1276,7 +1284,7 @@ Nothing()
Just('nana')
```
-
+
Takes an index and a list and returns Just the element of the list at
the index if the index is within the list's bounds; Nothing otherwise.
@@ -1293,7 +1301,7 @@ Nothing()
Just('d')
```
-
+
Takes a list and returns Just the first element of the list if the
list contains at least one element; Nothing if the list is empty.
@@ -1306,7 +1314,7 @@ Just(1)
Nothing()
```
-
+
Takes a list and returns Just the last element of the list if the
list contains at least one element; Nothing if the list is empty.
@@ -1319,7 +1327,7 @@ Just(3)
Nothing()
```
-
+
Takes a list and returns Just a list containing all but the first
of the list's elements if the list contains at least one element;
@@ -1333,7 +1341,7 @@ Just([2, 3])
Nothing()
```
-
+
Takes a list and returns Just a list containing all but the last
of the list's elements if the list contains at least one element;
@@ -1347,7 +1355,7 @@ Just([1, 2])
Nothing()
```
-
+
Returns Just the first N elements of the given collection if N is
greater than or equal to zero and less than or equal to the length
@@ -1365,7 +1373,7 @@ Just('abcd')
Nothing()
```
-
+
Returns Just the last N elements of the given collection if N is
greater than or equal to zero and less than or equal to the length
@@ -1383,7 +1391,7 @@ Just('defg')
Nothing()
```
-
+
Returns Just all but the first N elements of the given collection
if N is greater than or equal to zero and less than or equal to the
@@ -1401,7 +1409,7 @@ Just('efg')
Nothing()
```
-
+
Returns Just all but the last N elements of the given collection
if N is greater than or equal to zero and less than or equal to the
@@ -1419,7 +1427,7 @@ Just('abc')
Nothing()
```
-
+
Takes a predicate and a list and returns Just the leftmost element of
the list which satisfies the predicate; Nothing if none of the list's
@@ -1433,7 +1441,7 @@ Just(-2)
Nothing()
```
-
+
Takes a value of any type and a list, and returns Just the index
of the first occurrence of the value in the list, if applicable;
@@ -1457,7 +1465,7 @@ Just(1)
Nothing()
```
-
+
Takes a value of any type and a list, and returns Just the index
of the last occurrence of the value in the list, if applicable;
@@ -1481,7 +1489,7 @@ Just(3)
Nothing()
```
-
+
Takes a [type representative](#type-representatives), a property name,
and a list of objects and returns a list of equal length. Each element
@@ -1496,7 +1504,7 @@ See also [`get`](#get).
[Just(1), Just(2), Nothing(), Nothing(), Nothing()]
```
-
+
Takes a binary function, an initial value, and a [Foldable][], and
applies the function to the initial value and the Foldable's first
@@ -1514,7 +1522,7 @@ otherwise.
[5, 4, 3, 2, 1]
```
-
+
Takes a function and a seed value, and returns a list generated by
applying the function repeatedly. The list is initially empty. The
@@ -1533,7 +1541,7 @@ of the function should result in either:
### Object
-
+
Takes a [type representative](#type-representatives), a property
name, and an object and returns Just the value of the specified object
@@ -1556,7 +1564,7 @@ Nothing()
Nothing()
```
-
+
Takes a [type representative](#type-representatives), a list of property
names, and an object and returns Just the value at the path specified by
@@ -1578,7 +1586,7 @@ Nothing()
### Number
-
+
Negates its argument.
@@ -1590,7 +1598,7 @@ Negates its argument.
42
```
-
+
Returns the sum of two (finite) numbers.
@@ -1599,7 +1607,7 @@ Returns the sum of two (finite) numbers.
2
```
-
+
Returns the difference between two (finite) numbers.
@@ -1608,7 +1616,7 @@ Returns the difference between two (finite) numbers.
2
```
-
+
Increments a (finite) number by one.
@@ -1617,7 +1625,7 @@ Increments a (finite) number by one.
2
```
-
+
Decrements a (finite) number by one.
@@ -1626,7 +1634,7 @@ Decrements a (finite) number by one.
1
```
-
+
Returns the product of two (finite) numbers.
@@ -1635,7 +1643,7 @@ Returns the product of two (finite) numbers.
8
```
-
+
Returns the result of dividing its first argument (a finite number) by
its second argument (a non-zero finite number).
@@ -1645,7 +1653,7 @@ its second argument (a non-zero finite number).
3.5
```
-
+
Returns the smaller of its two arguments.
@@ -1666,7 +1674,7 @@ new Date('1999-12-31')
'10'
```
-
+
Returns the larger of its two arguments.
@@ -1689,7 +1697,7 @@ new Date('2000-01-01')
### Integer
-
+
Returns `true` if the given integer is even; `false` if it is odd.
@@ -1701,7 +1709,7 @@ true
false
```
-
+
Returns `true` if the given integer is odd; `false` if it is even.
@@ -1715,7 +1723,7 @@ false
### Parse
-
+
Takes a string and returns Just the date represented by the string
if it does in fact represent a date; Nothing otherwise.
@@ -1728,7 +1736,7 @@ Just(new Date('2011-01-19T17:40:00.000Z'))
Nothing()
```
-
+
Takes a string and returns Just the number represented by the string
if it does in fact represent a number; Nothing otherwise.
@@ -1741,7 +1749,7 @@ Just(-123.45)
Nothing()
```
-
+
Takes a radix (an integer between 2 and 36 inclusive) and a string,
and returns Just the number represented by the string if it does in
@@ -1763,7 +1771,7 @@ Just(255)
Nothing()
```
-
+
Takes a string which may or may not be valid JSON, and returns Just
the result of applying `JSON.parse` to the string if valid; Nothing
@@ -1779,7 +1787,7 @@ Nothing()
### RegExp
-
+
Takes a [RegexFlags][] and a pattern, and returns a RegExp.
@@ -1788,7 +1796,7 @@ Takes a [RegexFlags][] and a pattern, and returns a RegExp.
/:\d+:/g
```
-
+
Takes a string which may contain regular expression metacharacters,
and returns a string with those metacharacters escaped.
@@ -1802,7 +1810,7 @@ Properties:
'\\-=\\*\\{XYZ\\}\\*=\\-'
```
-
+
Takes a pattern and a string, and returns `true` if the pattern
matches the string; `false` otherwise.
@@ -1815,7 +1823,7 @@ true
false
```
-
+
Takes a pattern and a string, and returns Just a list of matches
if the pattern matches the string; Nothing otherwise. Each match
@@ -1832,7 +1840,7 @@ Just([Just('bye'), Nothing()])
### String
-
+
Returns the upper-case equivalent of its argument.
@@ -1843,7 +1851,7 @@ See also [`toLower`](#toLower).
'ABC DEF 123'
```
-
+
Returns the lower-case equivalent of its argument.
@@ -1854,7 +1862,7 @@ See also [`toUpper`](#toUpper).
'abc def 123'
```
-
+
Takes a string and returns the list of words the string contains
(words are delimited by whitespace characters).
@@ -1866,7 +1874,7 @@ See also [`unwords`](#unwords).
['foo', 'bar', 'baz']
```
-
+
Takes a list of words and returns the result of joining the words
with separating spaces.
@@ -1878,7 +1886,7 @@ See also [`words`](#words).
'foo bar baz'
```
-
+
Takes a string and returns the list of lines the string contains
(lines are delimited by newlines: `'\n'` or `'\r\n'` or `'\r'`).
@@ -1891,7 +1899,7 @@ See also [`unlines`](#unlines).
['foo', 'bar', 'baz']
```
-
+
Takes a list of lines and returns the result of joining the lines
after appending a terminating line feed (`'\n'`) to each.
diff --git a/bower.json b/bower.json
index 40cd5a1e..c11f442e 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "sanctuary",
- "version": "0.9.1",
+ "version": "0.10.0",
"description": "Refuge from unsafe JavaScript",
"license": "MIT",
"repository": {
diff --git a/package.json b/package.json
index ae35e02e..3f71f961 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "sanctuary",
- "version": "0.9.1",
+ "version": "0.10.0",
"description": "Refuge from unsafe JavaScript",
"license": "MIT",
"repository": {