Comparing version 0.8.0 to 0.9.0
{ | ||
"name": "sanctuary", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "Refuge from unsafe JavaScript", | ||
@@ -12,3 +12,3 @@ "license": "MIT", | ||
"ramda": "0.19.x", | ||
"sanctuary-def": "0.3.x" | ||
"sanctuary-def": "0.4.x" | ||
}, | ||
@@ -15,0 +15,0 @@ "devDependencies": { |
620
README.md
@@ -95,2 +95,40 @@ # Sanctuary | ||
## Type checking | ||
Sanctuary functions are defined via [sanctuary-def][] to provide run-time | ||
type checking. This is tremendously useful during development: type errors | ||
are reported immediately, avoiding circuitous stack traces (at best) and | ||
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" | ||
``` | ||
Compare this to the behaviour of Ramda's unchecked equivalent: | ||
```javascript | ||
R.inc('XXX'); | ||
// => '1XXX' | ||
``` | ||
There is a performance cost to run-time type checking. One may wish to | ||
disable type checking in certain contexts to avoid paying this cost. | ||
There are actually two versions of the Sanctuary module: one with type | ||
checking; one without. The latter is accessible via the `unchecked` | ||
property of the former. | ||
When application of `S.unchecked.<name>` honours the function's type | ||
signature the result will be the same as if `S.<name>` had been used | ||
instead. Otherwise, the behaviour is unspecified. | ||
In Node, one could use an environment variable to determine which version | ||
of the Sanctuary module to use: | ||
```javascript | ||
const S = process.env.NODE_ENV === 'production' ? | ||
require('sanctuary').unchecked : | ||
require('sanctuary'); | ||
``` | ||
## API | ||
@@ -100,3 +138,3 @@ | ||
<h4 name="type"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L286">type :: a -> String</a></code></h4> | ||
<h4 name="type"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L341">type :: a -> String</a></code></h4> | ||
@@ -120,3 +158,3 @@ Takes a value, `x`, of any type and returns its type identifier. If | ||
<h4 name="is"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L310">is :: TypeRep a -> b -> Boolean</a></code></h4> | ||
<h4 name="is"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L365">is :: TypeRep a -> b -> Boolean</a></code></h4> | ||
@@ -140,3 +178,3 @@ Takes a [type representative](#type-representatives) and a value of | ||
<h4 name="I"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L340">I :: a -> a</a></code></h4> | ||
<h4 name="I"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L395">I :: a -> a</a></code></h4> | ||
@@ -151,3 +189,3 @@ The I combinator. Returns its argument. Equivalent to Haskell's `id` | ||
<h4 name="K"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L355">K :: a -> b -> a</a></code></h4> | ||
<h4 name="K"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L410">K :: a -> b -> a</a></code></h4> | ||
@@ -165,5 +203,60 @@ The K combinator. Takes two values and returns the first. Equivalent to | ||
<h4 name="A"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L428">A :: (a -> b) -> a -> b</a></code></h4> | ||
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) | ||
2 | ||
> R.map(S.A(R.__, 100), [R.inc, Math.sqrt]) | ||
[101, 10] | ||
``` | ||
<h4 name="C"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L446">C :: (a -> b -> c) -> b -> a -> c</a></code></h4> | ||
The C combinator. Takes a curried binary function and two values, and | ||
returns the result of applying the function to the values in reverse. | ||
Equivalent to Haskell's `flip` function. | ||
This function is very similar to [`flip`](#flip), except that its first | ||
argument must be curried. This allows it to work with manually curried | ||
functions. | ||
```javascript | ||
> S.C(R.concat, 'foo', 'bar') | ||
'barfoo' | ||
> R.filter(S.C(R.gt, 0), [-1, -2, 3, -4, 4, 2]) | ||
[3, 4, 2] | ||
``` | ||
<h4 name="B"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L469">B :: (b -> c) -> (a -> b) -> a -> c</a></code></h4> | ||
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 | ||
value. Equivalent to [`compose`](#compose) and Haskell's `(.)` function. | ||
```javascript | ||
> S.B(Math.sqrt, S.inc, 99) | ||
10 | ||
``` | ||
<h4 name="S"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L485">S :: (a -> b -> c) -> (a -> b) -> a -> c</a></code></h4> | ||
The S combinator. Takes a curried binary function, a unary function, | ||
and a value, and returns the result of applying the binary function to: | ||
- the value; and | ||
- the result of applying the unary function to the value. | ||
```javascript | ||
> S.S(R.add, Math.sqrt, 100) | ||
110 | ||
``` | ||
### Function | ||
<h4 name="flip"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L375">flip :: (a -> b -> c) -> b -> a -> c</a></code></h4> | ||
<h4 name="flip"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L505">flip :: (a -> b -> c) -> b -> a -> c</a></code></h4> | ||
@@ -175,2 +268,4 @@ Takes a binary function and two values and returns the result of | ||
See also [`C`](#C). | ||
```javascript | ||
@@ -181,3 +276,3 @@ > R.map(S.flip(Math.pow)(2), [1, 2, 3, 4, 5]) | ||
<h4 name="lift"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L392">lift :: Functor f => (a -> b) -> f a -> f b</a></code></h4> | ||
<h4 name="lift"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L524">lift :: Functor f => (a -> b) -> f a -> f b</a></code></h4> | ||
@@ -187,10 +282,10 @@ Promotes a unary function to a function which operates on a [Functor][]. | ||
```javascript | ||
> S.lift(R.inc, S.Just(2)) | ||
S.Just(3) | ||
> S.lift(S.inc, S.Just(2)) | ||
Just(3) | ||
> S.lift(R.inc, S.Nothing()) | ||
S.Nothing() | ||
> S.lift(S.inc, S.Nothing()) | ||
Nothing() | ||
``` | ||
<h4 name="lift2"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L409">lift2 :: Apply f => (a -> b -> c) -> f a -> f b -> f c</a></code></h4> | ||
<h4 name="lift2"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L541">lift2 :: Apply f => (a -> b -> c) -> f a -> f b -> f c</a></code></h4> | ||
@@ -202,15 +297,15 @@ Promotes a binary function to a function which operates on two | ||
> S.lift2(R.add, S.Just(2), S.Just(3)) | ||
S.Just(5) | ||
Just(5) | ||
> S.lift2(R.add, S.Just(2), S.Nothing()) | ||
S.Nothing() | ||
Nothing() | ||
> S.lift2(S.and, S.Just(true), S.Just(true)) | ||
S.Just(true) | ||
Just(true) | ||
> S.lift2(S.and, S.Just(true), S.Just(false)) | ||
S.Just(false) | ||
Just(false) | ||
``` | ||
<h4 name="lift3"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L433">lift3 :: Apply f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d</a></code></h4> | ||
<h4 name="lift3"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L565">lift3 :: Apply f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d</a></code></h4> | ||
@@ -221,7 +316,7 @@ Promotes a ternary function to a function which operates on three | ||
```javascript | ||
> S.lift3(R.reduce, S.Just(R.add), S.Just(0), S.Just([1, 2, 3])) | ||
S.Just(6) | ||
> S.lift3(S.reduce, S.Just(S.add), S.Just(0), S.Just([1, 2, 3])) | ||
Just(6) | ||
> S.lift3(R.reduce, S.Just(R.add), S.Just(0), S.Nothing()) | ||
S.Nothing() | ||
> S.lift3(S.reduce, S.Just(S.add), S.Just(0), S.Nothing()) | ||
Nothing() | ||
``` | ||
@@ -231,3 +326,3 @@ | ||
<h4 name="compose"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L453">compose :: (b -> c) -> (a -> b) -> a -> c</a></code></h4> | ||
<h4 name="compose"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L585">compose :: (b -> c) -> (a -> b) -> a -> c</a></code></h4> | ||
@@ -241,10 +336,10 @@ Takes two functions assumed to be unary and a value of any type, | ||
See also [`pipe`](#pipe). | ||
See also [`B`](#B) and [`pipe`](#pipe). | ||
```javascript | ||
> S.compose(Math.sqrt, R.inc)(99) | ||
> S.compose(Math.sqrt, S.inc)(99) | ||
10 | ||
``` | ||
<h4 name="pipe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L474">pipe :: [(a -> b), (b -> c), ..., (m -> n)] -> a -> n</a></code></h4> | ||
<h4 name="pipe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L606">pipe :: [(a -> b), (b -> c), ..., (m -> n)] -> a -> n</a></code></h4> | ||
@@ -261,7 +356,7 @@ Takes a list of functions assumed to be unary and a value of any type, | ||
```javascript | ||
> S.pipe([R.inc, Math.sqrt, R.dec])(99) | ||
> S.pipe([S.inc, Math.sqrt, S.dec])(99) | ||
9 | ||
``` | ||
<h4 name="meld"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L495">meld :: [** -> *] -> (* -> * -> ... -> *)</a></code></h4> | ||
<h4 name="meld"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L627">meld :: [** -> *] -> (* -> * -> ... -> *)</a></code></h4> | ||
@@ -286,6 +381,6 @@ Takes a list of non-nullary functions and returns a curried function | ||
```javascript | ||
> S.meld([Math.pow, R.subtract])(3, 4, 5) | ||
> S.meld([Math.pow, S.sub])(3, 4, 5) | ||
76 | ||
> S.meld([Math.pow, R.subtract])(3)(4)(5) | ||
> S.meld([Math.pow, S.sub])(3)(4)(5) | ||
76 | ||
@@ -296,12 +391,18 @@ ``` | ||
<h4 name="Maybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L538">Maybe :: TypeRep Maybe</a></code></h4> | ||
The Maybe type represents optional values: a value of type `Maybe a` is | ||
either a Just whose value is of type `a` or a Nothing (with no value). | ||
The Maybe type satisfies the [Monoid][], [Monad][], [Foldable][], and | ||
[Extend][] specifications. | ||
The Maybe type satisfies the [Monoid][], [Monad][], [Traversable][], | ||
and [Extend][] specifications. | ||
<h4 name="Maybe.empty"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L551">Maybe.empty :: -> Maybe a</a></code></h4> | ||
<h4 name="MaybeType"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L676">MaybeType :: Type -> Type</a></code></h4> | ||
A [`UnaryType`][UnaryType] for use with [sanctuary-def][]. | ||
<h4 name="Maybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L680">Maybe :: TypeRep Maybe</a></code></h4> | ||
The [type representative](#type-representatives) for the Maybe type. | ||
<h4 name="Maybe.empty"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L689">Maybe.empty :: -> Maybe a</a></code></h4> | ||
Returns a Nothing. | ||
@@ -314,3 +415,3 @@ | ||
<h4 name="Maybe.of"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L565">Maybe.of :: a -> Maybe a</a></code></h4> | ||
<h4 name="Maybe.of"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L703">Maybe.of :: a -> Maybe a</a></code></h4> | ||
@@ -324,7 +425,7 @@ Takes a value of any type and returns a Just with the given value. | ||
<h4 name="Maybe.prototype.@@type"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L579">Maybe#@@type :: String</a></code></h4> | ||
<h4 name="Maybe.prototype.@@type"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L717">Maybe#@@type :: String</a></code></h4> | ||
Maybe type identifier, `'sanctuary/Maybe'`. | ||
<h4 name="Maybe.prototype.isNothing"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L584">Maybe#isNothing :: Boolean</a></code></h4> | ||
<h4 name="Maybe.prototype.isNothing"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L722">Maybe#isNothing :: Boolean</a></code></h4> | ||
@@ -341,3 +442,3 @@ `true` if `this` is a Nothing; `false` if `this` is a Just. | ||
<h4 name="Maybe.prototype.isJust"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L596">Maybe#isJust :: Boolean</a></code></h4> | ||
<h4 name="Maybe.prototype.isJust"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L734">Maybe#isJust :: Boolean</a></code></h4> | ||
@@ -354,3 +455,3 @@ `true` if `this` is a Just; `false` if `this` is a Nothing. | ||
<h4 name="Maybe.prototype.ap"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L608">Maybe#ap :: Maybe (a -> b) ~> Maybe a -> Maybe b</a></code></h4> | ||
<h4 name="Maybe.prototype.ap"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L746">Maybe#ap :: Maybe (a -> b) ~> Maybe a -> Maybe b</a></code></h4> | ||
@@ -366,10 +467,10 @@ Takes a value of type `Maybe a` and returns a Nothing unless `this` | ||
> S.Just(R.inc).ap(S.Nothing()) | ||
> S.Just(S.inc).ap(S.Nothing()) | ||
Nothing() | ||
> S.Just(R.inc).ap(S.Just(42)) | ||
> S.Just(S.inc).ap(S.Just(42)) | ||
Just(43) | ||
``` | ||
<h4 name="Maybe.prototype.chain"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L631">Maybe#chain :: Maybe a ~> (a -> Maybe b) -> Maybe b</a></code></h4> | ||
<h4 name="Maybe.prototype.chain"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L769">Maybe#chain :: Maybe a ~> (a -> Maybe b) -> Maybe b</a></code></h4> | ||
@@ -390,3 +491,3 @@ Takes a function and returns `this` if `this` is a Nothing; otherwise | ||
<h4 name="Maybe.prototype.concat"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L652">Maybe#concat :: Semigroup a => Maybe a ~> Maybe a -> Maybe a</a></code></h4> | ||
<h4 name="Maybe.prototype.concat"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L790">Maybe#concat :: Semigroup a => Maybe a ~> Maybe a -> Maybe a</a></code></h4> | ||
@@ -420,3 +521,3 @@ Returns the result of concatenating two Maybe values of the same type. | ||
<h4 name="Maybe.prototype.empty"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L689">Maybe#empty :: Maybe a ~> Maybe a</a></code></h4> | ||
<h4 name="Maybe.prototype.empty"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L827">Maybe#empty :: Maybe a ~> Maybe a</a></code></h4> | ||
@@ -430,3 +531,3 @@ Returns a Nothing. | ||
<h4 name="Maybe.prototype.equals"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L703">Maybe#equals :: Maybe a ~> b -> Boolean</a></code></h4> | ||
<h4 name="Maybe.prototype.equals"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L841">Maybe#equals :: Maybe a ~> b -> Boolean</a></code></h4> | ||
@@ -457,3 +558,3 @@ Takes a value of any type and returns `true` if: | ||
<h4 name="Maybe.prototype.extend"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L738">Maybe#extend :: Maybe a ~> (Maybe a -> a) -> Maybe a</a></code></h4> | ||
<h4 name="Maybe.prototype.extend"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L876">Maybe#extend :: Maybe a ~> (Maybe a -> a) -> Maybe a</a></code></h4> | ||
@@ -472,3 +573,3 @@ Takes a function and returns `this` if `this` is a Nothing; otherwise | ||
<h4 name="Maybe.prototype.filter"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L757">Maybe#filter :: Maybe a ~> (a -> Boolean) -> Maybe a</a></code></h4> | ||
<h4 name="Maybe.prototype.filter"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L895">Maybe#filter :: Maybe a ~> (a -> Boolean) -> Maybe a</a></code></h4> | ||
@@ -486,3 +587,3 @@ Takes a predicate and returns `this` if `this` is a Just whose value | ||
<h4 name="Maybe.prototype.map"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L775">Maybe#map :: Maybe a ~> (a -> b) -> Maybe b</a></code></h4> | ||
<h4 name="Maybe.prototype.map"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L913">Maybe#map :: Maybe a ~> (a -> b) -> Maybe b</a></code></h4> | ||
@@ -494,3 +595,3 @@ Takes a function and returns `this` if `this` is a Nothing; otherwise | ||
```javascript | ||
> S.Nothing().map(R.inc) | ||
> S.Nothing().map(S.inc) | ||
Nothing() | ||
@@ -502,3 +603,3 @@ | ||
<h4 name="Maybe.prototype.of"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L796">Maybe#of :: Maybe a ~> b -> Maybe b</a></code></h4> | ||
<h4 name="Maybe.prototype.of"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L934">Maybe#of :: Maybe a ~> b -> Maybe b</a></code></h4> | ||
@@ -512,3 +613,3 @@ Takes a value of any type and returns a Just with the given value. | ||
<h4 name="Maybe.prototype.reduce"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L810">Maybe#reduce :: Maybe a ~> (b -> a -> b) -> b -> b</a></code></h4> | ||
<h4 name="Maybe.prototype.reduce"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L948">Maybe#reduce :: Maybe a ~> (b -> a -> b) -> b -> b</a></code></h4> | ||
@@ -523,11 +624,27 @@ Takes a function and an initial value of any type, and returns: | ||
```javascript | ||
> S.Nothing().reduce(R.add, 10) | ||
> S.Nothing().reduce(S.add, 10) | ||
10 | ||
> S.Just(5).reduce(R.add, 10) | ||
> S.Just(5).reduce(S.add, 10) | ||
15 | ||
``` | ||
<h4 name="Maybe.prototype.toBoolean"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L834">Maybe#toBoolean :: Maybe a ~> Boolean</a></code></h4> | ||
<h4 name="Maybe.prototype.sequence"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L972">Maybe#sequence :: Applicative f => Maybe (f a) ~> (a -> f a) -> f (Maybe a)</a></code></h4> | ||
Evaluates an applicative action contained within the Maybe, resulting in: | ||
- a pure applicative of a Nothing if `this` is a Nothing; otherwise | ||
- an applicative of Just the value of the evaluated action. | ||
```javascript | ||
> S.Nothing().sequence(S.Either.of) | ||
Right(Nothing()) | ||
> S.Just(Right(42)).sequence(S.Either.of) | ||
Right(Just(42)) | ||
``` | ||
<h4 name="Maybe.prototype.toBoolean"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L995">Maybe#toBoolean :: Maybe a ~> Boolean</a></code></h4> | ||
Returns `false` if `this` is a Nothing; `true` if `this` is a Just. | ||
@@ -543,3 +660,3 @@ | ||
<h4 name="Maybe.prototype.toString"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L851">Maybe#toString :: Maybe a ~> String</a></code></h4> | ||
<h4 name="Maybe.prototype.toString"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1012">Maybe#toString :: Maybe a ~> String</a></code></h4> | ||
@@ -556,3 +673,3 @@ Returns the string representation of the Maybe. | ||
<h4 name="Maybe.prototype.inspect"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L871">Maybe#inspect :: Maybe a ~> String</a></code></h4> | ||
<h4 name="Maybe.prototype.inspect"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1032">Maybe#inspect :: Maybe a ~> String</a></code></h4> | ||
@@ -572,3 +689,3 @@ Returns the string representation of the Maybe. This method is used by | ||
<h4 name="Nothing"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L887">Nothing :: -> Maybe a</a></code></h4> | ||
<h4 name="Nothing"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1048">Nothing :: -> Maybe a</a></code></h4> | ||
@@ -583,3 +700,3 @@ Returns a Nothing. Though this is a constructor function the `new` | ||
<h4 name="Just"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L903">Just :: a -> Maybe a</a></code></h4> | ||
<h4 name="Just"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1064">Just :: a -> Maybe a</a></code></h4> | ||
@@ -595,3 +712,3 @@ Takes a value of any type and returns a Just with the given value. | ||
<h4 name="isNothing"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L921">isNothing :: Maybe a -> Boolean</a></code></h4> | ||
<h4 name="isNothing"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1082">isNothing :: Maybe a -> Boolean</a></code></h4> | ||
@@ -608,3 +725,3 @@ Returns `true` if the given Maybe is a Nothing; `false` if it is a Just. | ||
<h4 name="isJust"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L938">isJust :: Maybe a -> Boolean</a></code></h4> | ||
<h4 name="isJust"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1099">isJust :: Maybe a -> Boolean</a></code></h4> | ||
@@ -621,3 +738,3 @@ Returns `true` if the given Maybe is a Just; `false` if it is a Nothing. | ||
<h4 name="fromMaybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L955">fromMaybe :: a -> Maybe a -> a</a></code></h4> | ||
<h4 name="fromMaybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1116">fromMaybe :: a -> Maybe a -> a</a></code></h4> | ||
@@ -635,3 +752,3 @@ Takes a default value and a Maybe, and returns the Maybe's value | ||
<h4 name="toMaybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L973">toMaybe :: a? -> Maybe a</a></code></h4> | ||
<h4 name="toMaybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1134">toMaybe :: a? -> Maybe a</a></code></h4> | ||
@@ -649,3 +766,3 @@ Takes a value and returns Nothing if the value is null or undefined; | ||
<h4 name="maybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L991">maybe :: b -> (a -> b) -> Maybe a -> b</a></code></h4> | ||
<h4 name="maybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1152">maybe :: b -> (a -> b) -> Maybe a -> b</a></code></h4> | ||
@@ -664,3 +781,3 @@ Takes a value of any type, a function, and a Maybe. If the Maybe is | ||
<h4 name="catMaybes"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1010">catMaybes :: [Maybe a] -> [a]</a></code></h4> | ||
<h4 name="catMaybes"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1171">catMaybes :: [Maybe a] -> [a]</a></code></h4> | ||
@@ -674,3 +791,3 @@ Takes a list of Maybes and returns a list containing each Just's value. | ||
<h4 name="mapMaybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1024">mapMaybe :: (a -> Maybe b) -> [a] -> [b]</a></code></h4> | ||
<h4 name="mapMaybe"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1185">mapMaybe :: (a -> Maybe b) -> [a] -> [b]</a></code></h4> | ||
@@ -690,3 +807,3 @@ Takes a function and a list, applies the function to each element of | ||
<h4 name="encase"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1044">encase :: (a -> b) -> a -> Maybe b</a></code></h4> | ||
<h4 name="encase"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1205">encase :: (a -> b) -> a -> Maybe b</a></code></h4> | ||
@@ -708,7 +825,7 @@ Takes a unary function `f` which may throw and a value `x` of any type, | ||
<h4 name="encase2"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1072">encase2 :: (a -> b -> c) -> a -> b -> Maybe c</a></code></h4> | ||
<h4 name="encase2"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1233">encase2 :: (a -> b -> c) -> a -> b -> Maybe c</a></code></h4> | ||
Binary version of [`encase`](#encase). | ||
<h4 name="encase3"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1087">encase3 :: (a -> b -> c -> d) -> a -> b -> c -> Maybe d</a></code></h4> | ||
<h4 name="encase3"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1248">encase3 :: (a -> b -> c -> d) -> a -> b -> c -> Maybe d</a></code></h4> | ||
@@ -719,4 +836,2 @@ Ternary version of [`encase`](#encase). | ||
<h4 name="Either"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1104">Either :: TypeRep Either</a></code></h4> | ||
The Either type represents values with two possibilities: a value of type | ||
@@ -729,4 +844,12 @@ `Either a b` is either a Left whose value is of type `a` or a Right whose | ||
<h4 name="Either.of"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1118">Either.of :: b -> Either a b</a></code></h4> | ||
<h4 name="EitherType"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1272">EitherType :: Type -> Type -> Type</a></code></h4> | ||
A [`BinaryType`][BinaryType] for use with [sanctuary-def][]. | ||
<h4 name="Either"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1276">Either :: TypeRep Either</a></code></h4> | ||
The [type representative](#type-representatives) for the Either type. | ||
<h4 name="Either.of"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1285">Either.of :: b -> Either a b</a></code></h4> | ||
Takes a value of any type and returns a Right with the given value. | ||
@@ -739,7 +862,7 @@ | ||
<h4 name="Either.prototype.@@type"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1132">Either#@@type :: String</a></code></h4> | ||
<h4 name="Either.prototype.@@type"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1299">Either#@@type :: String</a></code></h4> | ||
Either type identifier, `'sanctuary/Either'`. | ||
<h4 name="Either.prototype.isLeft"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1137">Either#isLeft :: Boolean</a></code></h4> | ||
<h4 name="Either.prototype.isLeft"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1304">Either#isLeft :: Boolean</a></code></h4> | ||
@@ -756,3 +879,3 @@ `true` if `this` is a Left; `false` if `this` is a Right. | ||
<h4 name="Either.prototype.isRight"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1149">Either#isRight :: Boolean</a></code></h4> | ||
<h4 name="Either.prototype.isRight"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1316">Either#isRight :: Boolean</a></code></h4> | ||
@@ -769,3 +892,3 @@ `true` if `this` is a Right; `false` if `this` is a Left. | ||
<h4 name="Either.prototype.ap"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1161">Either#ap :: Either a (b -> c) ~> Either a b -> Either a c</a></code></h4> | ||
<h4 name="Either.prototype.ap"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1328">Either#ap :: Either a (b -> c) ~> Either a b -> Either a c</a></code></h4> | ||
@@ -781,10 +904,10 @@ Takes a value of type `Either a b` and returns a Left unless `this` | ||
> S.Right(R.inc).ap(S.Left('Cannot divide by zero')) | ||
> S.Right(S.inc).ap(S.Left('Cannot divide by zero')) | ||
Left('Cannot divide by zero') | ||
> S.Right(R.inc).ap(S.Right(42)) | ||
> S.Right(S.inc).ap(S.Right(42)) | ||
Right(43) | ||
``` | ||
<h4 name="Either.prototype.chain"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1184">Either#chain :: Either a b ~> (b -> Either a c) -> Either a c</a></code></h4> | ||
<h4 name="Either.prototype.chain"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1351">Either#chain :: Either a b ~> (b -> Either a c) -> Either a c</a></code></h4> | ||
@@ -810,3 +933,3 @@ Takes a function and returns `this` if `this` is a Left; otherwise | ||
<h4 name="Either.prototype.concat"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1212">Either#concat :: (Semigroup a, Semigroup b) => Either a b ~> Either a b -> Either a b</a></code></h4> | ||
<h4 name="Either.prototype.concat"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1379">Either#concat :: (Semigroup a, Semigroup b) => Either a b ~> Either a b -> Either a b</a></code></h4> | ||
@@ -841,3 +964,3 @@ Returns the result of concatenating two Either values of the same type. | ||
<h4 name="Either.prototype.equals"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1251">Either#equals :: Either a b ~> c -> Boolean</a></code></h4> | ||
<h4 name="Either.prototype.equals"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1418">Either#equals :: Either a b ~> c -> Boolean</a></code></h4> | ||
@@ -863,3 +986,3 @@ Takes a value of any type and returns `true` if: | ||
<h4 name="Either.prototype.extend"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1280">Either#extend :: Either a b ~> (Either a b -> b) -> Either a b</a></code></h4> | ||
<h4 name="Either.prototype.extend"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1447">Either#extend :: Either a b ~> (Either a b -> b) -> Either a b</a></code></h4> | ||
@@ -878,3 +1001,3 @@ Takes a function and returns `this` if `this` is a Left; otherwise it | ||
<h4 name="Either.prototype.map"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1301">Either#map :: Either a b ~> (b -> c) -> Either a c</a></code></h4> | ||
<h4 name="Either.prototype.map"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1468">Either#map :: Either a b ~> (b -> c) -> Either a c</a></code></h4> | ||
@@ -886,3 +1009,3 @@ Takes a function and returns `this` if `this` is a Left; otherwise it | ||
```javascript | ||
> S.Left('Cannot divide by zero').map(R.inc) | ||
> S.Left('Cannot divide by zero').map(S.inc) | ||
Left('Cannot divide by zero') | ||
@@ -894,3 +1017,3 @@ | ||
<h4 name="Either.prototype.of"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1322">Either#of :: Either a b ~> c -> Either a c</a></code></h4> | ||
<h4 name="Either.prototype.of"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1489">Either#of :: Either a b ~> c -> Either a c</a></code></h4> | ||
@@ -904,3 +1027,3 @@ Takes a value of any type and returns a Right with the given value. | ||
<h4 name="Either.prototype.toBoolean"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1336">Either#toBoolean :: Either a b ~> Boolean</a></code></h4> | ||
<h4 name="Either.prototype.toBoolean"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1503">Either#toBoolean :: Either a b ~> Boolean</a></code></h4> | ||
@@ -917,3 +1040,3 @@ Returns `false` if `this` is a Left; `true` if `this` is a Right. | ||
<h4 name="Either.prototype.toString"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1353">Either#toString :: Either a b ~> String</a></code></h4> | ||
<h4 name="Either.prototype.toString"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1520">Either#toString :: Either a b ~> String</a></code></h4> | ||
@@ -930,3 +1053,3 @@ Returns the string representation of the Either. | ||
<h4 name="Either.prototype.inspect"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1373">Either#inspect :: Either a b ~> String</a></code></h4> | ||
<h4 name="Either.prototype.inspect"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1540">Either#inspect :: Either a b ~> String</a></code></h4> | ||
@@ -946,3 +1069,3 @@ Returns the string representation of the Either. This method is used by | ||
<h4 name="Left"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1389">Left :: a -> Either a b</a></code></h4> | ||
<h4 name="Left"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1556">Left :: a -> Either a b</a></code></h4> | ||
@@ -958,3 +1081,3 @@ Takes a value of any type and returns a Left with the given value. | ||
<h4 name="Right"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1407">Right :: b -> Either a b</a></code></h4> | ||
<h4 name="Right"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1574">Right :: b -> Either a b</a></code></h4> | ||
@@ -970,3 +1093,3 @@ Takes a value of any type and returns a Right with the given value. | ||
<h4 name="isLeft"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1425">isLeft :: Either a b -> Boolean</a></code></h4> | ||
<h4 name="isLeft"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1592">isLeft :: Either a b -> Boolean</a></code></h4> | ||
@@ -983,3 +1106,3 @@ Returns `true` if the given Either is a Left; `false` if it is a Right. | ||
<h4 name="isRight"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1442">isRight :: Either a b -> Boolean</a></code></h4> | ||
<h4 name="isRight"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1609">isRight :: Either a b -> Boolean</a></code></h4> | ||
@@ -996,3 +1119,3 @@ Returns `true` if the given Either is a Right; `false` if it is a Left. | ||
<h4 name="either"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1459">either :: (a -> c) -> (b -> c) -> Either a b -> c</a></code></h4> | ||
<h4 name="either"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1626">either :: (a -> c) -> (b -> c) -> Either a b -> c</a></code></h4> | ||
@@ -1005,11 +1128,33 @@ Takes two functions and an Either, and returns the result of | ||
```javascript | ||
> S.either(R.toUpper, R.toString, S.Left('Cannot divide by zero')) | ||
> S.either(S.toUpper, R.toString, S.Left('Cannot divide by zero')) | ||
'CANNOT DIVIDE BY ZERO' | ||
> S.either(R.toUpper, R.toString, S.Right(42)) | ||
> S.either(S.toUpper, R.toString, S.Right(42)) | ||
'42' | ||
``` | ||
<h4 name="encaseEither"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1481">encaseEither :: (Error -> l) -> (a -> r) -> a -> Either l r</a></code></h4> | ||
<h4 name="lefts"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1648">lefts :: [Either a b] -> [a]</a></code></h4> | ||
Takes a list of Eithers and returns a list containing each Left's value. | ||
See also [`rights`](#rights). | ||
```javascript | ||
> S.lefts([S.Right(20), S.Left('foo'), S.Right(10), S.Left('bar')]) | ||
['foo', 'bar'] | ||
``` | ||
<h4 name="rights"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1666">rights :: [Either a b] -> [b]</a></code></h4> | ||
Takes a list of Eithers and returns a list containing each Right's value. | ||
See also [`lefts`](#lefts). | ||
```javascript | ||
> S.rights([S.Right(20), S.Left('foo'), S.Right(10), S.Left('bar')]) | ||
[20, 10] | ||
``` | ||
<h4 name="encaseEither"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1684">encaseEither :: (Error -> l) -> (a -> r) -> a -> Either l r</a></code></h4> | ||
Takes two unary functions, `f` and `g`, the second of which may throw, | ||
@@ -1034,11 +1179,11 @@ and a value `x` of any type. Applies `g` to `x` inside a `try` block. | ||
<h4 name="encaseEither2"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1513">encaseEither2 :: (Error -> l) -> (a -> b -> r) -> a -> b -> Either l r</a></code></h4> | ||
<h4 name="encaseEither2"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1716">encaseEither2 :: (Error -> l) -> (a -> b -> r) -> a -> b -> Either l r</a></code></h4> | ||
Binary version of [`encaseEither`](#encaseEither). | ||
<h4 name="encaseEither3"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1528">encaseEither3 :: (Error -> l) -> (a -> b -> c -> r) -> a -> b -> c -> Either l r</a></code></h4> | ||
<h4 name="encaseEither3"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1731">encaseEither3 :: (Error -> l) -> (a -> b -> c -> r) -> a -> b -> c -> Either l r</a></code></h4> | ||
Ternary version of [`encaseEither`](#encaseEither). | ||
<h4 name="maybeToEither"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1543">maybeToEither :: a -> Maybe b -> Either a b</a></code></h4> | ||
<h4 name="maybeToEither"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1746">maybeToEither :: a -> Maybe b -> Either a b</a></code></h4> | ||
@@ -1060,3 +1205,3 @@ Takes a value of any type and a Maybe, and returns an Either. | ||
<h4 name="and"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1593">and :: Alternative a => a -> a -> a</a></code></h4> | ||
<h4 name="and"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1796">and :: Alternative a => a -> a -> a</a></code></h4> | ||
@@ -1077,3 +1222,3 @@ Takes two values of the same type and returns the second value | ||
<h4 name="or"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1614">or :: Alternative a => a -> a -> a</a></code></h4> | ||
<h4 name="or"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1817">or :: Alternative a => a -> a -> a</a></code></h4> | ||
@@ -1093,3 +1238,3 @@ Takes two values of the same type and returns the first value if it | ||
<h4 name="xor"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1634">xor :: (Alternative a, Monoid a) => a -> a -> a</a></code></h4> | ||
<h4 name="xor"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1837">xor :: (Alternative a, Monoid a) => a -> a -> a</a></code></h4> | ||
@@ -1113,3 +1258,3 @@ Takes two values of the same type and returns the "true" value | ||
<h4 name="not"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1660">not :: Boolean -> Boolean</a></code></h4> | ||
<h4 name="not"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1863">not :: Boolean -> Boolean</a></code></h4> | ||
@@ -1127,3 +1272,3 @@ Takes a Boolean and returns the negation of that value | ||
<h4 name="ifElse"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1678">ifElse :: (a -> Boolean) -> (a -> b) -> (a -> b) -> a -> b</a></code></h4> | ||
<h4 name="ifElse"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1881">ifElse :: (a -> Boolean) -> (a -> b) -> (a -> b) -> a -> b</a></code></h4> | ||
@@ -1144,3 +1289,3 @@ Takes a unary predicate, a unary "if" function, a unary "else" | ||
<h4 name="allPass"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1699">allPass :: [a -> Boolean] -> a -> Boolean</a></code></h4> | ||
<h4 name="allPass"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1902">allPass :: [a -> Boolean] -> a -> Boolean</a></code></h4> | ||
@@ -1160,3 +1305,3 @@ Takes an array of unary predicates and a value of any type | ||
<h4 name="anyPass"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1724">anyPass :: [a -> Boolean] -> a -> Boolean</a></code></h4> | ||
<h4 name="anyPass"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1927">anyPass :: [a -> Boolean] -> a -> Boolean</a></code></h4> | ||
@@ -1178,3 +1323,3 @@ Takes an array of unary predicates and a value of any type | ||
<h4 name="slice"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1751">slice :: Integer -> Integer -> [a] -> Maybe [a]</a></code></h4> | ||
<h4 name="slice"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1954">slice :: Integer -> Integer -> [a] -> Maybe [a]</a></code></h4> | ||
@@ -1208,3 +1353,3 @@ Returns Just a list containing the elements from the supplied list | ||
<h4 name="at"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1793">at :: Integer -> [a] -> Maybe a</a></code></h4> | ||
<h4 name="at"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L1996">at :: Integer -> [a] -> Maybe a</a></code></h4> | ||
@@ -1226,3 +1371,3 @@ Takes an index and a list and returns Just the element of the list at | ||
<h4 name="head"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1817">head :: [a] -> Maybe a</a></code></h4> | ||
<h4 name="head"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2020">head :: [a] -> Maybe a</a></code></h4> | ||
@@ -1240,3 +1385,3 @@ Takes a list and returns Just the first element of the list if the | ||
<h4 name="last"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1835">last :: [a] -> Maybe a</a></code></h4> | ||
<h4 name="last"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2038">last :: [a] -> Maybe a</a></code></h4> | ||
@@ -1254,3 +1399,3 @@ Takes a list and returns Just the last element of the list if the | ||
<h4 name="tail"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1853">tail :: [a] -> Maybe [a]</a></code></h4> | ||
<h4 name="tail"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2056">tail :: [a] -> Maybe [a]</a></code></h4> | ||
@@ -1269,3 +1414,3 @@ Takes a list and returns Just a list containing all but the first | ||
<h4 name="init"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1872">init :: [a] -> Maybe [a]</a></code></h4> | ||
<h4 name="init"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2075">init :: [a] -> Maybe [a]</a></code></h4> | ||
@@ -1284,3 +1429,3 @@ Takes a list and returns Just a list containing all but the last | ||
<h4 name="take"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1891">take :: Integer -> [a] -> Maybe [a]</a></code></h4> | ||
<h4 name="take"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2094">take :: Integer -> [a] -> Maybe [a]</a></code></h4> | ||
@@ -1303,3 +1448,3 @@ Returns Just the first N elements of the given collection if N is | ||
<h4 name="takeLast"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1916">takeLast :: Integer -> [a] -> Maybe [a]</a></code></h4> | ||
<h4 name="takeLast"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2119">takeLast :: Integer -> [a] -> Maybe [a]</a></code></h4> | ||
@@ -1322,3 +1467,3 @@ Returns Just the last N elements of the given collection if N is | ||
<h4 name="drop"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1941">drop :: Integer -> [a] -> Maybe [a]</a></code></h4> | ||
<h4 name="drop"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2144">drop :: Integer -> [a] -> Maybe [a]</a></code></h4> | ||
@@ -1341,3 +1486,3 @@ Returns Just all but the first N elements of the given collection | ||
<h4 name="dropLast"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1966">dropLast :: Integer -> [a] -> Maybe [a]</a></code></h4> | ||
<h4 name="dropLast"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2169">dropLast :: Integer -> [a] -> Maybe [a]</a></code></h4> | ||
@@ -1360,3 +1505,3 @@ Returns Just all but the last N elements of the given collection | ||
<h4 name="find"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L1991">find :: (a -> Boolean) -> [a] -> Maybe a</a></code></h4> | ||
<h4 name="find"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2194">find :: (a -> Boolean) -> [a] -> Maybe a</a></code></h4> | ||
@@ -1375,3 +1520,3 @@ Takes a predicate and a list and returns Just the leftmost element of | ||
<h4 name="indexOf"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2034">indexOf :: a -> [a] -> Maybe Integer</a></code></h4> | ||
<h4 name="indexOf"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2237">indexOf :: a -> [a] -> Maybe Integer</a></code></h4> | ||
@@ -1400,3 +1545,3 @@ Takes a value of any type and a list, and returns Just the index | ||
<h4 name="lastIndexOf"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2059">lastIndexOf :: a -> [a] -> Maybe Integer</a></code></h4> | ||
<h4 name="lastIndexOf"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2262">lastIndexOf :: a -> [a] -> Maybe Integer</a></code></h4> | ||
@@ -1425,3 +1570,3 @@ Takes a value of any type and a list, and returns Just the index | ||
<h4 name="pluck"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2084">pluck :: Accessible a => TypeRep b -> String -> [a] -> [Maybe b]</a></code></h4> | ||
<h4 name="pluck"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2287">pluck :: Accessible a => TypeRep b -> String -> [a] -> [Maybe b]</a></code></h4> | ||
@@ -1441,4 +1586,22 @@ Takes a [type representative](#type-representatives), a property name, | ||
<h4 name="unfoldr"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2104">unfoldr :: (b -> Maybe (a, b)) -> b -> [a]</a></code></h4> | ||
<h4 name="reduce"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2307">reduce :: Foldable f => (a -> b -> a) -> a -> f b -> a</a></code></h4> | ||
Takes a binary function, an initial value, and a [Foldable][], and | ||
applies the function to the initial value and the Foldable's first | ||
value, then applies the function to the result of the previous | ||
application and the Foldable's second value. Repeats this process | ||
until each of the Foldable's values has been used. Returns the initial | ||
value if the Foldable is empty; the result of the final application | ||
otherwise. | ||
```javascript | ||
> S.reduce(S.add, 0, [1, 2, 3, 4, 5]) | ||
15 | ||
> S.reduce((xs, x) => [x].concat(xs), [], [1, 2, 3, 4, 5]) | ||
[5, 4, 3, 2, 1] | ||
``` | ||
<h4 name="unfoldr"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2340">unfoldr :: (b -> Maybe (a, b)) -> b -> [a]</a></code></h4> | ||
Takes a function and a seed value, and returns a list generated by | ||
@@ -1461,3 +1624,3 @@ applying the function repeatedly. The list is initially empty. The | ||
<h4 name="get"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2136">get :: Accessible a => TypeRep b -> String -> a -> Maybe b</a></code></h4> | ||
<h4 name="get"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2372">get :: Accessible a => TypeRep b -> String -> a -> Maybe b</a></code></h4> | ||
@@ -1485,3 +1648,3 @@ Takes a [type representative](#type-representatives), a property | ||
<h4 name="gets"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2164">gets :: Accessible a => TypeRep b -> [String] -> a -> Maybe b</a></code></h4> | ||
<h4 name="gets"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2400">gets :: Accessible a => TypeRep b -> [String] -> a -> Maybe b</a></code></h4> | ||
@@ -1506,5 +1669,142 @@ Takes a [type representative](#type-representatives), a list of property | ||
### Number | ||
<h4 name="negate"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2436">negate :: ValidNumber -> ValidNumber</a></code></h4> | ||
Negates its argument. | ||
```javascript | ||
> S.negate(12.5) | ||
-12.5 | ||
> S.negate(-42) | ||
42 | ||
``` | ||
<h4 name="add"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2453">add :: FiniteNumber -> FiniteNumber -> FiniteNumber</a></code></h4> | ||
Returns the sum of two (finite) numbers. | ||
```javascript | ||
> S.add(1, 1) | ||
2 | ||
``` | ||
<h4 name="sub"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2467">sub :: FiniteNumber -> FiniteNumber -> FiniteNumber</a></code></h4> | ||
Returns the difference between two (finite) numbers. | ||
```javascript | ||
> S.sub(4, 2) | ||
2 | ||
``` | ||
<h4 name="inc"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2481">inc :: FiniteNumber -> FiniteNumber</a></code></h4> | ||
Increments a (finite) number by one. | ||
```javascript | ||
> S.inc(1) | ||
2 | ||
``` | ||
<h4 name="dec"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2495">dec :: FiniteNumber -> FiniteNumber</a></code></h4> | ||
Decrements a (finite) number by one. | ||
```javascript | ||
> S.dec(2) | ||
1 | ||
``` | ||
<h4 name="mult"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2509">mult :: FiniteNumber -> FiniteNumber -> FiniteNumber</a></code></h4> | ||
Returns the product of two (finite) numbers. | ||
```javascript | ||
> S.mult(4, 2) | ||
8 | ||
``` | ||
<h4 name="div"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2523">div :: FiniteNumber -> NonZeroFiniteNumber -> FiniteNumber</a></code></h4> | ||
Returns the result of dividing its first argument (a finite number) by | ||
its second argument (a non-zero finite number). | ||
```javascript | ||
> S.div(7, 2) | ||
3.5 | ||
``` | ||
<h4 name="min"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2538">min :: Ord a => a -> a -> a</a></code></h4> | ||
Returns the smaller of its two arguments. | ||
Strings are compared lexicographically. Specifically, the Unicode | ||
code point value of each character in the first string is compared | ||
to the value of the corresponding character in the second string. | ||
See also [`max`](#max). | ||
```javascript | ||
> S.min(10, 2) | ||
2 | ||
> S.min(new Date('1999-12-31'), new Date('2000-01-01')) | ||
new Date('1999-12-31') | ||
> S.min('10', '2') | ||
'10' | ||
``` | ||
<h4 name="max"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2564">max :: Ord a => a -> a -> a</a></code></h4> | ||
Returns the larger of its two arguments. | ||
Strings are compared lexicographically. Specifically, the Unicode | ||
code point value of each character in the first string is compared | ||
to the value of the corresponding character in the second string. | ||
See also [`min`](#min). | ||
```javascript | ||
> S.max(10, 2) | ||
10 | ||
> S.max(new Date('1999-12-31'), new Date('2000-01-01')) | ||
new Date('2000-01-01') | ||
> S.max('10', '2') | ||
'2' | ||
``` | ||
### Integer | ||
<h4 name="even"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2592">even :: Integer -> Boolean</a></code></h4> | ||
Returns `true` if the given integer is even; `false` if it is odd. | ||
```javascript | ||
> S.even(42) | ||
true | ||
> S.even(99) | ||
false | ||
``` | ||
<h4 name="odd"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2609">odd :: Integer -> Boolean</a></code></h4> | ||
Returns `true` if the given integer is odd; `false` if it is even. | ||
```javascript | ||
> S.odd(99) | ||
true | ||
> S.odd(42) | ||
false | ||
``` | ||
### Parse | ||
<h4 name="parseDate"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2200">parseDate :: String -> Maybe Date</a></code></h4> | ||
<h4 name="parseDate"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2628">parseDate :: String -> Maybe Date</a></code></h4> | ||
@@ -1522,3 +1822,3 @@ Takes a string and returns Just the date represented by the string | ||
<h4 name="parseFloat"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2255">parseFloat :: String -> Maybe Number</a></code></h4> | ||
<h4 name="parseFloat"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2683">parseFloat :: String -> Maybe Number</a></code></h4> | ||
@@ -1536,3 +1836,3 @@ Takes a string and returns Just the number represented by the string | ||
<h4 name="parseInt"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2273">parseInt :: Integer -> String -> Maybe Integer</a></code></h4> | ||
<h4 name="parseInt"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2701">parseInt :: Integer -> String -> Maybe Integer</a></code></h4> | ||
@@ -1559,3 +1859,3 @@ Takes a radix (an integer between 2 and 36 inclusive) and a string, | ||
<h4 name="parseJson"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2318">parseJson :: String -> Maybe Any</a></code></h4> | ||
<h4 name="parseJson"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2746">parseJson :: String -> Maybe Any</a></code></h4> | ||
@@ -1576,3 +1876,3 @@ Takes a string which may or may not be valid JSON, and returns Just | ||
<h4 name="regex"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2339">regex :: RegexFlags -> String -> RegExp</a></code></h4> | ||
<h4 name="regex"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2767">regex :: RegexFlags -> String -> RegExp</a></code></h4> | ||
@@ -1586,3 +1886,3 @@ Takes a [RegexFlags][] and a pattern, and returns a RegExp. | ||
<h4 name="regexEscape"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2353">regexEscape :: String -> String</a></code></h4> | ||
<h4 name="regexEscape"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2781">regexEscape :: String -> String</a></code></h4> | ||
@@ -1601,3 +1901,3 @@ Takes a string which may contain regular expression metacharacters, | ||
<h4 name="test"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2372">test :: RegExp -> String -> Boolean</a></code></h4> | ||
<h4 name="test"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2800">test :: RegExp -> String -> Boolean</a></code></h4> | ||
@@ -1615,3 +1915,3 @@ Takes a pattern and a string, and returns `true` if the pattern | ||
<h4 name="match"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2395">match :: RegExp -> String -> Maybe [Maybe String]</a></code></h4> | ||
<h4 name="match"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2823">match :: RegExp -> String -> Maybe [Maybe String]</a></code></h4> | ||
@@ -1633,4 +1933,26 @@ Takes a pattern and a string, and returns Just a list of matches | ||
<h4 name="words"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2419">words :: String -> [String]</a></code></h4> | ||
<h4 name="toUpper"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2847">toUpper :: String -> String</a></code></h4> | ||
Returns the upper-case equivalent of its argument. | ||
See also [`toLower`](#toLower). | ||
```javascript | ||
> S.toUpper('ABC def 123') | ||
'ABC DEF 123' | ||
``` | ||
<h4 name="toLower"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2863">toLower :: String -> String</a></code></h4> | ||
Returns the lower-case equivalent of its argument. | ||
See also [`toUpper`](#toUpper). | ||
```javascript | ||
> S.toLower('ABC def 123') | ||
'abc def 123' | ||
``` | ||
<h4 name="words"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2879">words :: String -> [String]</a></code></h4> | ||
Takes a string and returns the list of words the string contains | ||
@@ -1646,3 +1968,3 @@ (words are delimited by whitespace characters). | ||
<h4 name="unwords"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2436">unwords :: [String] -> String</a></code></h4> | ||
<h4 name="unwords"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2896">unwords :: [String] -> String</a></code></h4> | ||
@@ -1659,3 +1981,3 @@ Takes a list of words and returns the result of joining the words | ||
<h4 name="lines"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2453">lines :: String -> [String]</a></code></h4> | ||
<h4 name="lines"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2913">lines :: String -> [String]</a></code></h4> | ||
@@ -1673,3 +1995,3 @@ Takes a string and returns the list of lines the string contains | ||
<h4 name="unlines"><code><a href="https://github.com/plaid/sanctuary/blob/v0.8.0/index.js#L2471">unlines :: [String] -> String</a></code></h4> | ||
<h4 name="unlines"><code><a href="https://github.com/plaid/sanctuary/blob/v0.9.0/index.js#L2931">unlines :: [String] -> String</a></code></h4> | ||
@@ -1686,15 +2008,19 @@ Takes a list of lines and returns the result of joining the lines | ||
[Apply]: https://github.com/fantasyland/fantasy-land#apply | ||
[Extend]: https://github.com/fantasyland/fantasy-land#extend | ||
[Foldable]: https://github.com/fantasyland/fantasy-land#foldable | ||
[Functor]: https://github.com/fantasyland/fantasy-land#functor | ||
[Monad]: https://github.com/fantasyland/fantasy-land#monad | ||
[Monoid]: https://github.com/fantasyland/fantasy-land#monoid | ||
[R.equals]: http://ramdajs.com/docs/#equals | ||
[R.map]: http://ramdajs.com/docs/#map | ||
[R.type]: http://ramdajs.com/docs/#type | ||
[Ramda]: http://ramdajs.com/ | ||
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp | ||
[RegexFlags]: https://github.com/plaid/sanctuary-def#regexflags | ||
[Semigroup]: https://github.com/fantasyland/fantasy-land#semigroup | ||
[parseInt]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt | ||
[Apply]: https://github.com/fantasyland/fantasy-land#apply | ||
[BinaryType]: https://github.com/plaid/sanctuary-def#binarytype | ||
[Extend]: https://github.com/fantasyland/fantasy-land#extend | ||
[Foldable]: https://github.com/fantasyland/fantasy-land#foldable | ||
[Functor]: https://github.com/fantasyland/fantasy-land#functor | ||
[Monad]: https://github.com/fantasyland/fantasy-land#monad | ||
[Monoid]: https://github.com/fantasyland/fantasy-land#monoid | ||
[R.equals]: http://ramdajs.com/docs/#equals | ||
[R.map]: http://ramdajs.com/docs/#map | ||
[R.type]: http://ramdajs.com/docs/#type | ||
[Ramda]: http://ramdajs.com/ | ||
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp | ||
[RegexFlags]: https://github.com/plaid/sanctuary-def#regexflags | ||
[Semigroup]: https://github.com/fantasyland/fantasy-land#semigroup | ||
[Traversable]: https://github.com/fantasyland/fantasy-land#traversable | ||
[UnaryType]: https://github.com/plaid/sanctuary-def#unarytype | ||
[parseInt]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt | ||
[sanctuary-def]: https://github.com/plaid/sanctuary-def |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146621
2787
1924
+ Addedsanctuary-def@0.4.0(transitive)
- Removedsanctuary-def@0.3.0(transitive)
Updatedsanctuary-def@0.4.x