diff --git a/LICENSE b/LICENSE
index 1a41c06..ab65140 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2018 Sanctuary
+Copyright (c) 2019 Sanctuary
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
diff --git a/README.md b/README.md
index 8c6dda8..b663c8e 100644
--- a/README.md
+++ b/README.md
@@ -53,7 +53,7 @@ This project provides:
## API
-#### `TypeClass :: (String, String, Array TypeClass, a -> Boolean) -> TypeClass`
+#### `TypeClass :: (String, String, Array TypeClass, a -> Boolean) -> TypeClass`
The arguments are:
@@ -71,19 +71,19 @@ Example:
const hasMethod = name => x => x != null && typeof x[name] == 'function';
// Foo :: TypeClass
-const Foo = Z.TypeClass(
+const Foo = Z.TypeClass (
'my-package/Foo',
'http://example.com/my-package#Foo',
[],
- hasMethod('foo')
+ hasMethod ('foo')
);
// Bar :: TypeClass
-const Bar = Z.TypeClass(
+const Bar = Z.TypeClass (
'my-package/Bar',
'http://example.com/my-package#Bar',
[Foo],
- hasMethod('bar')
+ hasMethod ('bar')
);
```
@@ -100,292 +100,292 @@ dependencies; `false` otherwise.
to define parametrically polymorphic functions which verify their
type-class constraints at run time.
-#### `Setoid :: TypeClass`
+#### `Setoid :: TypeClass`
`TypeClass` value for [Setoid][].
```javascript
-> Setoid.test(null)
+> Setoid.test (null)
true
```
-#### `Ord :: TypeClass`
+#### `Ord :: TypeClass`
`TypeClass` value for [Ord][].
```javascript
-> Ord.test(0)
+> Ord.test (0)
true
-> Ord.test(Math.sqrt)
+> Ord.test (Math.sqrt)
false
```
-#### `Semigroupoid :: TypeClass`
+#### `Semigroupoid :: TypeClass`
`TypeClass` value for [Semigroupoid][].
```javascript
-> Semigroupoid.test(Math.sqrt)
+> Semigroupoid.test (Math.sqrt)
true
-> Semigroupoid.test(0)
+> Semigroupoid.test (0)
false
```
-#### `Category :: TypeClass`
+#### `Category :: TypeClass`
`TypeClass` value for [Category][].
```javascript
-> Category.test(Math.sqrt)
+> Category.test (Math.sqrt)
true
-> Category.test(0)
+> Category.test (0)
false
```
-#### `Semigroup :: TypeClass`
+#### `Semigroup :: TypeClass`
`TypeClass` value for [Semigroup][].
```javascript
-> Semigroup.test('')
+> Semigroup.test ('')
true
-> Semigroup.test(0)
+> Semigroup.test (0)
false
```
-#### `Monoid :: TypeClass`
+#### `Monoid :: TypeClass`
`TypeClass` value for [Monoid][].
```javascript
-> Monoid.test('')
+> Monoid.test ('')
true
-> Monoid.test(0)
+> Monoid.test (0)
false
```
-#### `Group :: TypeClass`
+#### `Group :: TypeClass`
`TypeClass` value for [Group][].
```javascript
-> Group.test(Sum(0))
+> Group.test (Sum (0))
true
-> Group.test('')
+> Group.test ('')
false
```
-#### `Filterable :: TypeClass`
+#### `Filterable :: TypeClass`
`TypeClass` value for [Filterable][].
```javascript
-> Filterable.test({})
+> Filterable.test ({})
true
-> Filterable.test('')
+> Filterable.test ('')
false
```
-#### `Functor :: TypeClass`
+#### `Functor :: TypeClass`
`TypeClass` value for [Functor][].
```javascript
-> Functor.test([])
+> Functor.test ([])
true
-> Functor.test('')
+> Functor.test ('')
false
```
-#### `Bifunctor :: TypeClass`
+#### `Bifunctor :: TypeClass`
`TypeClass` value for [Bifunctor][].
```javascript
-> Bifunctor.test(Tuple('foo', 64))
+> Bifunctor.test (Pair ('foo') (64))
true
-> Bifunctor.test([])
+> Bifunctor.test ([])
false
```
-#### `Profunctor :: TypeClass`
+#### `Profunctor :: TypeClass`
`TypeClass` value for [Profunctor][].
```javascript
-> Profunctor.test(Math.sqrt)
+> Profunctor.test (Math.sqrt)
true
-> Profunctor.test([])
+> Profunctor.test ([])
false
```
-#### `Apply :: TypeClass`
+#### `Apply :: TypeClass`
`TypeClass` value for [Apply][].
```javascript
-> Apply.test([])
+> Apply.test ([])
true
-> Apply.test('')
+> Apply.test ('')
false
```
-#### `Applicative :: TypeClass`
+#### `Applicative :: TypeClass`
`TypeClass` value for [Applicative][].
```javascript
-> Applicative.test([])
+> Applicative.test ([])
true
-> Applicative.test({})
+> Applicative.test ({})
false
```
-#### `Chain :: TypeClass`
+#### `Chain :: TypeClass`
`TypeClass` value for [Chain][].
```javascript
-> Chain.test([])
+> Chain.test ([])
true
-> Chain.test({})
+> Chain.test ({})
false
```
-#### `ChainRec :: TypeClass`
+#### `ChainRec :: TypeClass`
`TypeClass` value for [ChainRec][].
```javascript
-> ChainRec.test([])
+> ChainRec.test ([])
true
-> ChainRec.test({})
+> ChainRec.test ({})
false
```
-#### `Monad :: TypeClass`
+#### `Monad :: TypeClass`
`TypeClass` value for [Monad][].
```javascript
-> Monad.test([])
+> Monad.test ([])
true
-> Monad.test({})
+> Monad.test ({})
false
```
-#### `Alt :: TypeClass`
+#### `Alt :: TypeClass`
`TypeClass` value for [Alt][].
```javascript
-> Alt.test({})
+> Alt.test ({})
true
-> Alt.test('')
+> Alt.test ('')
false
```
-#### `Plus :: TypeClass`
+#### `Plus :: TypeClass`
`TypeClass` value for [Plus][].
```javascript
-> Plus.test({})
+> Plus.test ({})
true
-> Plus.test('')
+> Plus.test ('')
false
```
-#### `Alternative :: TypeClass`
+#### `Alternative :: TypeClass`
`TypeClass` value for [Alternative][].
```javascript
-> Alternative.test([])
+> Alternative.test ([])
true
-> Alternative.test({})
+> Alternative.test ({})
false
```
-#### `Foldable :: TypeClass`
+#### `Foldable :: TypeClass`
`TypeClass` value for [Foldable][].
```javascript
-> Foldable.test({})
+> Foldable.test ({})
true
-> Foldable.test('')
+> Foldable.test ('')
false
```
-#### `Traversable :: TypeClass`
+#### `Traversable :: TypeClass`
`TypeClass` value for [Traversable][].
```javascript
-> Traversable.test([])
+> Traversable.test ([])
true
-> Traversable.test('')
+> Traversable.test ('')
false
```
-#### `Extend :: TypeClass`
+#### `Extend :: TypeClass`
`TypeClass` value for [Extend][].
```javascript
-> Extend.test([])
+> Extend.test ([])
true
-> Extend.test({})
+> Extend.test ({})
false
```
-#### `Comonad :: TypeClass`
+#### `Comonad :: TypeClass`
`TypeClass` value for [Comonad][].
```javascript
-> Comonad.test(Identity(0))
+> Comonad.test (Identity (0))
true
-> Comonad.test([])
+> Comonad.test ([])
false
```
-#### `Contravariant :: TypeClass`
+#### `Contravariant :: TypeClass`
`TypeClass` value for [Contravariant][].
```javascript
-> Contravariant.test(Math.sqrt)
+> Contravariant.test (Math.sqrt)
true
-> Contravariant.test([])
+> Contravariant.test ([])
false
```
-#### `equals :: (a, b) -> Boolean`
+#### `equals :: (a, b) -> Boolean`
Returns `true` if its arguments are of the same type and equal according
to the type's [`fantasy-land/equals`][] method; `false` otherwise.
@@ -401,20 +401,20 @@ are equal even if their internal structures differ. Two objects are equal
if they have the same property paths and for each path have equal values.
```javascript
-> equals(0, -0)
+> equals (0, -0)
true
-> equals(NaN, NaN)
+> equals (NaN, NaN)
true
-> equals(Cons('foo', Cons('bar', Nil)), Cons('foo', Cons('bar', Nil)))
+> equals (Cons (1, Cons (2, Nil)), Cons (1, Cons (2, Nil)))
true
-> equals(Cons('foo', Cons('bar', Nil)), Cons('bar', Cons('foo', Nil)))
+> equals (Cons (1, Cons (2, Nil)), Cons (2, Cons (1, Nil)))
false
```
-#### `lt :: (a, b) -> Boolean`
+#### `lt :: (a, b) -> Boolean`
Returns `true` if its arguments are of the same type and the first is
less than the second according to the type's [`fantasy-land/lte`][]
@@ -425,17 +425,17 @@ This function is derived from [`lte`](#lte).
See also [`gt`](#gt) and [`gte`](#gte).
```javascript
-> lt(0, 0)
+> lt (0, 0)
false
-> lt(0, 1)
+> lt (0, 1)
true
-> lt(1, 0)
+> lt (1, 0)
false
```
-#### `lte :: (a, b) -> Boolean`
+#### `lte :: (a, b) -> Boolean`
Returns `true` if its arguments are of the same type and the first
is less than or equal to the second according to the type's
@@ -451,17 +451,17 @@ The algorithm supports circular data structures in the same manner as
See also [`lt`](#lt), [`gt`](#gt), and [`gte`](#gte).
```javascript
-> lte(0, 0)
+> lte (0, 0)
true
-> lte(0, 1)
+> lte (0, 1)
true
-> lte(1, 0)
+> lte (1, 0)
false
```
-#### `gt :: (a, b) -> Boolean`
+#### `gt :: (a, b) -> Boolean`
Returns `true` if its arguments are of the same type and the first is
greater than the second according to the type's [`fantasy-land/lte`][]
@@ -472,17 +472,17 @@ This function is derived from [`lte`](#lte).
See also [`lt`](#lt) and [`gte`](#gte).
```javascript
-> gt(0, 0)
+> gt (0, 0)
false
-> gt(0, 1)
+> gt (0, 1)
false
-> gt(1, 0)
+> gt (1, 0)
true
```
-#### `gte :: (a, b) -> Boolean`
+#### `gte :: (a, b) -> Boolean`
Returns `true` if its arguments are of the same type and the first
is greater than or equal to the second according to the type's
@@ -493,17 +493,17 @@ This function is derived from [`lte`](#lte).
See also [`lt`](#lt) and [`gt`](#gt).
```javascript
-> gte(0, 0)
+> gte (0, 0)
true
-> gte(0, 1)
+> gte (0, 1)
false
-> gte(1, 0)
+> gte (1, 0)
true
```
-#### `min :: Ord a => (a, a) -> a`
+#### `min :: Ord a => (a, a) -> a`
Returns the smaller of its two arguments.
@@ -512,17 +512,17 @@ This function is derived from [`lte`](#lte).
See also [`max`](#max).
```javascript
-> min(10, 2)
+> min (10, 2)
2
-> min(new Date('1999-12-31'), new Date('2000-01-01'))
-new Date('1999-12-31')
+> min (new Date ('1999-12-31'), new Date ('2000-01-01'))
+new Date ('1999-12-31')
-> min('10', '2')
+> min ('10', '2')
'10'
```
-#### `max :: Ord a => (a, a) -> a`
+#### `max :: Ord a => (a, a) -> a`
Returns the larger of its two arguments.
@@ -531,17 +531,35 @@ This function is derived from [`lte`](#lte).
See also [`min`](#min).
```javascript
-> max(10, 2)
+> max (10, 2)
10
-> max(new Date('1999-12-31'), new Date('2000-01-01'))
-new Date('2000-01-01')
+> max (new Date ('1999-12-31'), new Date ('2000-01-01'))
+new Date ('2000-01-01')
-> max('10', '2')
+> max ('10', '2')
'2'
```
-#### `compose :: Semigroupoid c => (c j k, c i j) -> c i k`
+#### `clamp :: Ord a => (a, a, a) -> a`
+
+Takes a lower bound, an upper bound, and a value of the same type.
+Returns the value if it is within the bounds; the nearer bound otherwise.
+
+This function is derived from [`min`](#min) and [`max`](#max).
+
+```javascript
+> clamp (0, 100, 42)
+42
+
+> clamp (0, 100, -1)
+0
+
+> clamp ('A', 'Z', '~')
+'Z'
+```
+
+#### `compose :: Semigroupoid c => (c j k, c i j) -> c i k`
Function wrapper for [`fantasy-land/compose`][].
@@ -549,11 +567,11 @@ Function wrapper for [`fantasy-land/compose`][].
built-in types: Function.
```javascript
-> compose(Math.sqrt, x => x + 1)(99)
+> compose (Math.sqrt, x => x + 1) (99)
10
```
-#### `id :: Category c => TypeRep c -> c`
+#### `id :: Category c => TypeRep c -> c`
Function wrapper for [`fantasy-land/id`][].
@@ -561,11 +579,11 @@ Function wrapper for [`fantasy-land/id`][].
built-in types: Function.
```javascript
-> id(Function)('foo')
+> id (Function) ('foo')
'foo'
```
-#### `concat :: Semigroup a => (a, a) -> a`
+#### `concat :: Semigroup a => (a, a) -> a`
Function wrapper for [`fantasy-land/concat`][].
@@ -573,20 +591,20 @@ Function wrapper for [`fantasy-land/concat`][].
built-in types: String, Array, and Object.
```javascript
-> concat('abc', 'def')
+> concat ('abc', 'def')
'abcdef'
-> concat([1, 2, 3], [4, 5, 6])
+> concat ([1, 2, 3], [4, 5, 6])
[1, 2, 3, 4, 5, 6]
-> concat({x: 1, y: 2}, {y: 3, z: 4})
+> concat ({x: 1, y: 2}, {y: 3, z: 4})
{x: 1, y: 3, z: 4}
-> concat(Cons('foo', Cons('bar', Cons('baz', Nil))), Cons('quux', Nil))
-Cons('foo', Cons('bar', Cons('baz', Cons('quux', Nil))))
+> concat (Cons ('foo', Cons ('bar', Cons ('baz', Nil))), Cons ('quux', Nil))
+Cons ('foo', Cons ('bar', Cons ('baz', Cons ('quux', Nil))))
```
-#### `empty :: Monoid m => TypeRep m -> m`
+#### `empty :: Monoid m => TypeRep m -> m`
Function wrapper for [`fantasy-land/empty`][].
@@ -594,29 +612,29 @@ Function wrapper for [`fantasy-land/empty`][].
built-in types: String, Array, and Object.
```javascript
-> empty(String)
+> empty (String)
''
-> empty(Array)
+> empty (Array)
[]
-> empty(Object)
+> empty (Object)
{}
-> empty(List)
+> empty (List)
Nil
```
-#### `invert :: Group g => g -> g`
+#### `invert :: Group g => g -> g`
Function wrapper for [`fantasy-land/invert`][].
```javascript
-> invert(Sum(5))
-Sum(-5)
+> invert (Sum (5))
+Sum (-5)
```
-#### `filter :: Filterable f => (a -> Boolean, f a) -> f a`
+#### `filter :: Filterable f => (a -> Boolean, f a) -> f a`
Function wrapper for [`fantasy-land/filter`][]. Discards every element
which does not satisfy the predicate.
@@ -627,52 +645,52 @@ built-in types: Array and Object.
See also [`reject`](#reject).
```javascript
-> filter(x => x % 2 == 1, [1, 2, 3])
+> filter (x => x % 2 == 1, [1, 2, 3])
[1, 3]
-> filter(x => x % 2 == 1, {x: 1, y: 2, z: 3})
+> filter (x => x % 2 == 1, {x: 1, y: 2, z: 3})
{x: 1, z: 3}
-> filter(x => x % 2 == 1, Cons(1, Cons(2, Cons(3, Nil))))
-Cons(1, Cons(3, Nil))
+> filter (x => x % 2 == 1, Cons (1, Cons (2, Cons (3, Nil))))
+Cons (1, Cons (3, Nil))
-> filter(x => x % 2 == 1, Nothing)
+> filter (x => x % 2 == 1, Nothing)
Nothing
-> filter(x => x % 2 == 1, Just(0))
+> filter (x => x % 2 == 1, Just (0))
Nothing
-> filter(x => x % 2 == 1, Just(1))
-Just(1)
+> filter (x => x % 2 == 1, Just (1))
+Just (1)
```
-#### `reject :: Filterable f => (a -> Boolean, f a) -> f a`
+#### `reject :: Filterable f => (a -> Boolean, f a) -> f a`
Discards every element which satisfies the predicate.
This function is derived from [`filter`](#filter).
```javascript
-> reject(x => x % 2 == 1, [1, 2, 3])
+> reject (x => x % 2 == 1, [1, 2, 3])
[2]
-> reject(x => x % 2 == 1, {x: 1, y: 2, z: 3})
+> reject (x => x % 2 == 1, {x: 1, y: 2, z: 3})
{y: 2}
-> reject(x => x % 2 == 1, Cons(1, Cons(2, Cons(3, Nil))))
-Cons(2, Nil)
+> reject (x => x % 2 == 1, Cons (1, Cons (2, Cons (3, Nil))))
+Cons (2, Nil)
-> reject(x => x % 2 == 1, Nothing)
+> reject (x => x % 2 == 1, Nothing)
Nothing
-> reject(x => x % 2 == 1, Just(0))
-Just(0)
+> reject (x => x % 2 == 1, Just (0))
+Just (0)
-> reject(x => x % 2 == 1, Just(1))
+> reject (x => x % 2 == 1, Just (1))
Nothing
```
-#### `takeWhile :: Filterable f => (a -> Boolean, f a) -> f a`
+#### `takeWhile :: Filterable f => (a -> Boolean, f a) -> f a`
Discards the first element which does not satisfy the predicate, and all
subsequent elements.
@@ -682,17 +700,17 @@ This function is derived from [`filter`](#filter).
See also [`dropWhile`](#dropWhile).
```javascript
-> takeWhile(s => /x/.test(s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
+> takeWhile (s => /x/.test (s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
['xy', 'xz', 'yx']
-> takeWhile(s => /y/.test(s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
+> takeWhile (s => /y/.test (s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
['xy']
-> takeWhile(s => /z/.test(s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
+> takeWhile (s => /z/.test (s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
[]
```
-#### `dropWhile :: Filterable f => (a -> Boolean, f a) -> f a`
+#### `dropWhile :: Filterable f => (a -> Boolean, f a) -> f a`
Retains the first element which does not satisfy the predicate, and all
subsequent elements.
@@ -702,17 +720,17 @@ This function is derived from [`filter`](#filter).
See also [`takeWhile`](#takeWhile).
```javascript
-> dropWhile(s => /x/.test(s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
+> dropWhile (s => /x/.test (s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
['yz', 'zx', 'zy']
-> dropWhile(s => /y/.test(s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
+> dropWhile (s => /y/.test (s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
['xz', 'yx', 'yz', 'zx', 'zy']
-> dropWhile(s => /z/.test(s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
+> dropWhile (s => /z/.test (s), ['xy', 'xz', 'yx', 'yz', 'zx', 'zy'])
['xy', 'xz', 'yx', 'yz', 'zx', 'zy']
```
-#### `map :: Functor f => (a -> b, f a) -> f b`
+#### `map :: Functor f => (a -> b, f a) -> f b`
Function wrapper for [`fantasy-land/map`][].
@@ -720,64 +738,64 @@ Function wrapper for [`fantasy-land/map`][].
built-in types: Array, Object, and Function.
```javascript
-> map(Math.sqrt, [1, 4, 9])
+> map (Math.sqrt, [1, 4, 9])
[1, 2, 3]
-> map(Math.sqrt, {x: 1, y: 4, z: 9})
+> map (Math.sqrt, {x: 1, y: 4, z: 9})
{x: 1, y: 2, z: 3}
-> map(Math.sqrt, s => s.length)('Sanctuary')
+> map (Math.sqrt, s => s.length) ('Sanctuary')
3
-> map(Math.sqrt, Tuple('foo', 64))
-Tuple('foo', 8)
+> map (Math.sqrt, Pair ('foo') (64))
+Pair ('foo') (8)
-> map(Math.sqrt, Nil)
+> map (Math.sqrt, Nil)
Nil
-> map(Math.sqrt, Cons(1, Cons(4, Cons(9, Nil))))
-Cons(1, Cons(2, Cons(3, Nil)))
+> map (Math.sqrt, Cons (1, Cons (4, Cons (9, Nil))))
+Cons (1, Cons (2, Cons (3, Nil)))
```
-#### `flip :: Functor f => (f (a -> b), a) -> f b`
+#### `flip :: Functor f => (f (a -> b), a) -> f b`
Maps over the given functions, applying each to the given value.
This function is derived from [`map`](#map).
```javascript
-> flip(x => y => x + y, '!')('foo')
+> flip (x => y => x + y, '!') ('foo')
'foo!'
-> flip([Math.floor, Math.ceil], 1.5)
+> flip ([Math.floor, Math.ceil], 1.5)
[1, 2]
-> flip({floor: Math.floor, ceil: Math.ceil}, 1.5)
+> flip ({floor: Math.floor, ceil: Math.ceil}, 1.5)
{floor: 1, ceil: 2}
-> flip(Cons(Math.floor, Cons(Math.ceil, Nil)), 1.5)
-Cons(1, Cons(2, Nil))
+> flip (Cons (Math.floor, Cons (Math.ceil, Nil)), 1.5)
+Cons (1, Cons (2, Nil))
```
-#### `bimap :: Bifunctor f => (a -> b, c -> d, f a c) -> f b d`
+#### `bimap :: Bifunctor f => (a -> b, c -> d, f a c) -> f b d`
Function wrapper for [`fantasy-land/bimap`][].
```javascript
-> bimap(s => s.toUpperCase(), Math.sqrt, Tuple('foo', 64))
-Tuple('FOO', 8)
+> bimap (s => s.toUpperCase (), Math.sqrt, Pair ('foo') (64))
+Pair ('FOO') (8)
```
-#### `mapLeft :: Bifunctor f => (a -> b, f a c) -> f b c`
+#### `mapLeft :: Bifunctor f => (a -> b, f a c) -> f b c`
Maps the given function over the left side of a Bifunctor.
```javascript
-> mapLeft(Math.sqrt, Tuple(64, 9))
-Tuple(8, 9)
+> mapLeft (Math.sqrt, Pair (64) (9))
+Pair (8) (9)
```
-#### `promap :: Profunctor p => (a -> b, c -> d, p b c) -> p a d`
+#### `promap :: Profunctor p => (a -> b, c -> d, p b c) -> p a d`
Function wrapper for [`fantasy-land/promap`][].
@@ -785,11 +803,11 @@ Function wrapper for [`fantasy-land/promap`][].
built-in types: Function.
```javascript
-> promap(Math.abs, x => x + 1, Math.sqrt)(-100)
+> promap (Math.abs, x => x + 1, Math.sqrt) (-100)
11
```
-#### `ap :: Apply f => (f (a -> b), f a) -> f b`
+#### `ap :: Apply f => (f (a -> b), f a) -> f b`
Function wrapper for [`fantasy-land/ap`][].
@@ -797,23 +815,23 @@ Function wrapper for [`fantasy-land/ap`][].
built-in types: Array, Object, and Function.
```javascript
-> ap([Math.sqrt, x => x * x], [1, 4, 9, 16, 25])
+> ap ([Math.sqrt, x => x * x], [1, 4, 9, 16, 25])
[1, 2, 3, 4, 5, 1, 16, 81, 256, 625]
-> ap({a: Math.sqrt, b: x => x * x}, {a: 16, b: 10, c: 1})
+> ap ({a: Math.sqrt, b: x => x * x}, {a: 16, b: 10, c: 1})
{a: 4, b: 100}
-> ap(s => n => s.slice(0, n), s => Math.ceil(s.length / 2))('Haskell')
+> ap (s => n => s.slice (0, n), s => Math.ceil (s.length / 2)) ('Haskell')
'Hask'
-> ap(Identity(Math.sqrt), Identity(64))
-Identity(8)
+> ap (Identity (Math.sqrt), Identity (64))
+Identity (8)
-> ap(Cons(Math.sqrt, Cons(x => x * x, Nil)), Cons(16, Cons(100, Nil)))
-Cons(4, Cons(10, Cons(256, Cons(10000, Nil))))
+> ap (Cons (Math.sqrt, Cons (x => x * x, Nil)), Cons (16, Cons (100, Nil)))
+Cons (4, Cons (10, Cons (256, Cons (10000, Nil))))
```
-#### `lift2 :: Apply f => (a -> b -> c, f a, f b) -> f c`
+#### `lift2 :: Apply f => (a -> b -> c, f a, f b) -> f c`
Lifts `a -> b -> c` to `Apply f => f a -> f b -> f c` and returns the
result of applying this to the given arguments.
@@ -823,14 +841,14 @@ This function is derived from [`map`](#map) and [`ap`](#ap).
See also [`lift3`](#lift3).
```javascript
-> lift2(x => y => Math.pow(x, y), [10], [1, 2, 3])
+> lift2 (x => y => Math.pow (x, y), [10], [1, 2, 3])
[10, 100, 1000]
-> lift2(x => y => Math.pow(x, y), Identity(10), Identity(3))
-Identity(1000)
+> lift2 (x => y => Math.pow (x, y), Identity (10), Identity (3))
+Identity (1000)
```
-#### `lift3 :: Apply f => (a -> b -> c -> d, f a, f b, f c) -> f d`
+#### `lift3 :: Apply f => (a -> b -> c -> d, f a, f b, f c) -> f d`
Lifts `a -> b -> c -> d` to `Apply f => f a -> f b -> f c -> f d` and
returns the result of applying this to the given arguments.
@@ -840,14 +858,23 @@ This function is derived from [`map`](#map) and [`ap`](#ap).
See also [`lift2`](#lift2).
```javascript
-> lift3(x => y => z => x + z + y, ['<'], ['>'], ['foo', 'bar', 'baz'])
-['', '', '']
+> lift3 (x => y => z => x + z + y,
+. ['<', '['],
+. ['>', ']'],
+. ['foo', 'bar', 'baz'])
+[ '', '', '',
+. '', '[bar>', '[baz>',
+. '[foo]', '[bar]', '[baz]' ]
-> lift3(x => y => z => x + z + y, Identity('<'), Identity('>'), Identity('baz'))
-Identity('')
+> lift3 (x => y => z => x + z + y,
+. Identity ('<'),
+. Identity ('>'),
+. Identity ('baz'))
+Identity ('')
```
-#### `apFirst :: Apply f => (f a, f b) -> f a`
+#### `apFirst :: Apply f => (f a, f b) -> f a`
Combines two effectful actions, keeping only the result of the first.
Equivalent to Haskell's `(<*)` function.
@@ -857,14 +884,14 @@ This function is derived from [`lift2`](#lift2).
See also [`apSecond`](#apSecond).
```javascript
-> apFirst([1, 2], [3, 4])
+> apFirst ([1, 2], [3, 4])
[1, 1, 2, 2]
-> apFirst(Identity(1), Identity(2))
-Identity(1)
+> apFirst (Identity (1), Identity (2))
+Identity (1)
```
-#### `apSecond :: Apply f => (f a, f b) -> f b`
+#### `apSecond :: Apply f => (f a, f b) -> f b`
Combines two effectful actions, keeping only the result of the second.
Equivalent to Haskell's `(*>)` function.
@@ -874,14 +901,14 @@ This function is derived from [`lift2`](#lift2).
See also [`apFirst`](#apFirst).
```javascript
-> apSecond([1, 2], [3, 4])
+> apSecond ([1, 2], [3, 4])
[3, 4, 3, 4]
-> apSecond(Identity(1), Identity(2))
-Identity(2)
+> apSecond (Identity (1), Identity (2))
+Identity (2)
```
-#### `of :: Applicative f => (TypeRep f, a) -> f a`
+#### `of :: Applicative f => (TypeRep f, a) -> f a`
Function wrapper for [`fantasy-land/of`][].
@@ -889,17 +916,17 @@ Function wrapper for [`fantasy-land/of`][].
built-in types: Array and Function.
```javascript
-> of(Array, 42)
+> of (Array, 42)
[42]
-> of(Function, 42)(null)
+> of (Function, 42) (null)
42
-> of(List, 42)
-Cons(42, Nil)
+> of (List, 42)
+Cons (42, Nil)
```
-#### `append :: (Applicative f, Semigroup (f a)) => (a, f a) -> f a`
+#### `append :: (Applicative f, Semigroup (f a)) => (a, f a) -> f a`
Returns the result of appending the first argument to the second.
@@ -908,14 +935,14 @@ This function is derived from [`concat`](#concat) and [`of`](#of).
See also [`prepend`](#prepend).
```javascript
-> append(3, [1, 2])
+> append (3, [1, 2])
[1, 2, 3]
-> append(3, Cons(1, Cons(2, Nil)))
-Cons(1, Cons(2, Cons(3, Nil)))
+> append (3, Cons (1, Cons (2, Nil)))
+Cons (1, Cons (2, Cons (3, Nil)))
```
-#### `prepend :: (Applicative f, Semigroup (f a)) => (a, f a) -> f a`
+#### `prepend :: (Applicative f, Semigroup (f a)) => (a, f a) -> f a`
Returns the result of prepending the first argument to the second.
@@ -924,14 +951,14 @@ This function is derived from [`concat`](#concat) and [`of`](#of).
See also [`append`](#append).
```javascript
-> prepend(1, [2, 3])
+> prepend (1, [2, 3])
[1, 2, 3]
-> prepend(1, Cons(2, Cons(3, Nil)))
-Cons(1, Cons(2, Cons(3, Nil)))
+> prepend (1, Cons (2, Cons (3, Nil)))
+Cons (1, Cons (2, Cons (3, Nil)))
```
-#### `chain :: Chain m => (a -> m b, m a) -> m b`
+#### `chain :: Chain m => (a -> m b, m a) -> m b`
Function wrapper for [`fantasy-land/chain`][].
@@ -939,34 +966,37 @@ Function wrapper for [`fantasy-land/chain`][].
built-in types: Array and Function.
```javascript
-> chain(x => [x, x], [1, 2, 3])
+> chain (x => [x, x], [1, 2, 3])
[1, 1, 2, 2, 3, 3]
-> chain(x => x % 2 == 1 ? of(List, x) : Nil, Cons(1, Cons(2, Cons(3, Nil))))
-Cons(1, Cons(3, Nil))
+> chain (x => x % 2 == 1 ? of (List, x) : Nil,
+. Cons (1, Cons (2, Cons (3, Nil))))
+Cons (1, Cons (3, Nil))
-> chain(n => s => s.slice(0, n), s => Math.ceil(s.length / 2))('Haskell')
+> chain (n => s => s.slice (0, n),
+. s => Math.ceil (s.length / 2))
+. ('Haskell')
'Hask'
```
-#### `join :: Chain m => m (m a) -> m a`
+#### `join :: Chain m => m (m a) -> m a`
Removes one level of nesting from a nested monadic structure.
This function is derived from [`chain`](#chain).
```javascript
-> join([[1], [2], [3]])
+> join ([[1], [2], [3]])
[1, 2, 3]
-> join([[[1, 2, 3]]])
+> join ([[[1, 2, 3]]])
[[1, 2, 3]]
-> join(Identity(Identity(1)))
-Identity(1)
+> join (Identity (Identity (1)))
+Identity (1)
```
-#### `chainRec :: ChainRec m => (TypeRep m, (a -> c, b -> c, a) -> m c, a) -> m b`
+#### `chainRec :: ChainRec m => (TypeRep m, (a -> c, b -> c, a) -> m c, a) -> m b`
Function wrapper for [`fantasy-land/chainRec`][].
@@ -974,16 +1004,16 @@ Function wrapper for [`fantasy-land/chainRec`][].
built-in types: Array.
```javascript
-> chainRec(
+> chainRec (
. Array,
-. (next, done, s) => s.length == 2 ? [s + '!', s + '?'].map(done)
-. : [s + 'o', s + 'n'].map(next),
+. (next, done, s) => s.length == 2 ? [s + '!', s + '?'].map (done)
+. : [s + 'o', s + 'n'].map (next),
. ''
. )
['oo!', 'oo?', 'on!', 'on?', 'no!', 'no?', 'nn!', 'nn?']
```
-#### `alt :: Alt f => (f a, f a) -> f a`
+#### `alt :: Alt f => (f a, f a) -> f a`
Function wrapper for [`fantasy-land/alt`][].
@@ -991,20 +1021,20 @@ Function wrapper for [`fantasy-land/alt`][].
built-in types: Array and Object.
```javascript
-> alt([1, 2, 3], [4, 5, 6])
+> alt ([1, 2, 3], [4, 5, 6])
[1, 2, 3, 4, 5, 6]
-> alt(Nothing, Nothing)
+> alt (Nothing, Nothing)
Nothing
-> alt(Nothing, Just(1))
-Just(1)
+> alt (Nothing, Just (1))
+Just (1)
-> alt(Just(2), Just(3))
-Just(2)
+> alt (Just (2), Just (3))
+Just (2)
```
-#### `zero :: Plus f => TypeRep f -> f a`
+#### `zero :: Plus f => TypeRep f -> f a`
Function wrapper for [`fantasy-land/zero`][].
@@ -1012,17 +1042,17 @@ Function wrapper for [`fantasy-land/zero`][].
built-in types: Array and Object.
```javascript
-> zero(Array)
+> zero (Array)
[]
-> zero(Object)
+> zero (Object)
{}
-> zero(Maybe)
+> zero (Maybe)
Nothing
```
-#### `reduce :: Foldable f => ((b, a) -> b, b, f a) -> b`
+#### `reduce :: Foldable f => ((b, a) -> b, b, f a) -> b`
Function wrapper for [`fantasy-land/reduce`][].
@@ -1030,34 +1060,92 @@ Function wrapper for [`fantasy-land/reduce`][].
built-in types: Array and Object.
```javascript
-> reduce((xs, x) => [x].concat(xs), [], [1, 2, 3])
+> reduce ((xs, x) => [x].concat (xs), [], [1, 2, 3])
[3, 2, 1]
-> reduce(concat, '', Cons('foo', Cons('bar', Cons('baz', Nil))))
+> reduce (concat, '', Cons ('foo', Cons ('bar', Cons ('baz', Nil))))
'foobarbaz'
```
-#### `size :: Foldable f => f a -> Integer`
+#### `size :: Foldable f => f a -> Integer`
Returns the number of elements of the given structure.
This function is derived from [`reduce`](#reduce).
```javascript
-> size([])
+> size ([])
0
-> size(['foo', 'bar', 'baz'])
+> size (['foo', 'bar', 'baz'])
3
-> size(Nil)
+> size (Nil)
0
-> size(Cons('foo', Cons('bar', Cons('baz', Nil))))
+> size (Cons ('foo', Cons ('bar', Cons ('baz', Nil))))
3
```
-#### `elem :: (Setoid a, Foldable f) => (a, f a) -> Boolean`
+#### `all :: Foldable f => (a -> Boolean, f a) -> Boolean`
+
+Returns `true` if all the elements of the structure satisfy the
+predicate; `false` otherwise.
+
+This function is derived from [`reduce`](#reduce).
+
+See also [`any`](#any) and [`none`](#none).
+
+```javascript
+> all (Number.isInteger, [])
+true
+
+> all (Number.isInteger, [1, 2, 3])
+true
+
+> all (Number.isInteger, [0, 0.25, 0.5, 0.75, 1])
+false
+```
+
+#### `any :: Foldable f => (a -> Boolean, f a) -> Boolean`
+
+Returns `true` if any element of the structure satisfies the predicate;
+`false` otherwise.
+
+This function is derived from [`reduce`](#reduce).
+
+See also [`all`](#all) and [`none`](#none).
+
+```javascript
+> any (Number.isInteger, [])
+false
+
+> any (Number.isInteger, [1, 2, 3])
+true
+
+> any (Number.isInteger, [0, 0.25, 0.5, 0.75, 1])
+true
+```
+
+#### `none :: Foldable f => (a -> Boolean, f a) -> Boolean`
+
+Returns `true` if none of the elements of the structure satisfies the
+predicate; `false` otherwise.
+
+This function is derived from [`any`](#any). `none (pred, foldable)` is
+equivalent to `!(any (pred, foldable))`.
+
+See also [`all`](#all).
+
+```javascript
+> none (Number.isInteger, [])
+true
+
+> none (Number.isInteger, [0, 0.25, 0.5, 0.75, 1])
+false
+```
+
+#### `elem :: (Setoid a, Foldable f) => (a, f a) -> Boolean`
Takes a value and a structure and returns `true` if the
value is an element of the structure; `false` otherwise.
@@ -1066,29 +1154,29 @@ This function is derived from [`equals`](#equals) and
[`reduce`](#reduce).
```javascript
-> elem('c', ['a', 'b', 'c'])
+> elem ('c', ['a', 'b', 'c'])
true
-> elem('x', ['a', 'b', 'c'])
+> elem ('x', ['a', 'b', 'c'])
false
-> elem(3, {x: 1, y: 2, z: 3})
+> elem (3, {x: 1, y: 2, z: 3})
true
-> elem(8, {x: 1, y: 2, z: 3})
+> elem (8, {x: 1, y: 2, z: 3})
false
-> elem(0, Just(0))
+> elem (0, Just (0))
true
-> elem(0, Just(1))
+> elem (0, Just (1))
false
-> elem(0, Nothing)
+> elem (0, Nothing)
false
```
-#### `foldMap :: (Monoid m, Foldable f) => (TypeRep m, a -> m, f a) -> m`
+#### `foldMap :: (Monoid m, Foldable f) => (TypeRep m, a -> m, f a) -> m`
Deconstructs a foldable by mapping every element to a monoid and
concatenating the results.
@@ -1097,11 +1185,11 @@ This function is derived from [`concat`](#concat), [`empty`](#empty),
and [`reduce`](#reduce).
```javascript
-> foldMap(String, f => f.name, [Math.sin, Math.cos, Math.tan])
+> foldMap (String, f => f.name, [Math.sin, Math.cos, Math.tan])
'sincostan'
```
-#### `reverse :: (Applicative f, Foldable f, Monoid (f a)) => f a -> f a`
+#### `reverse :: (Applicative f, Foldable f, Monoid (f a)) => f a -> f a`
Reverses the elements of the given structure.
@@ -1109,14 +1197,14 @@ This function is derived from [`concat`](#concat), [`empty`](#empty),
[`of`](#of), and [`reduce`](#reduce).
```javascript
-> reverse([1, 2, 3])
+> reverse ([1, 2, 3])
[3, 2, 1]
-> reverse(Cons(1, Cons(2, Cons(3, Nil))))
-Cons(3, Cons(2, Cons(1, Nil)))
+> reverse (Cons (1, Cons (2, Cons (3, Nil))))
+Cons (3, Cons (2, Cons (1, Nil)))
```
-#### `sort :: (Ord a, Applicative f, Foldable f, Monoid (f a)) => f a -> f a`
+#### `sort :: (Ord a, Applicative f, Foldable f, Monoid (f a)) => f a -> f a`
Performs a [stable sort][] of the elements of the given structure,
using [`lte`](#lte) for comparisons.
@@ -1127,17 +1215,17 @@ This function is derived from [`lte`](#lte), [`concat`](#concat),
See also [`sortBy`](#sortBy).
```javascript
-> sort(['foo', 'bar', 'baz'])
+> sort (['foo', 'bar', 'baz'])
['bar', 'baz', 'foo']
-> sort([Just(2), Nothing, Just(1)])
-[Nothing, Just(1), Just(2)]
+> sort ([Just (2), Nothing, Just (1)])
+[Nothing, Just (1), Just (2)]
-> sort(Cons('foo', Cons('bar', Cons('baz', Nil))))
-Cons('bar', Cons('baz', Cons('foo', Nil)))
+> sort (Cons ('foo', Cons ('bar', Cons ('baz', Nil))))
+Cons ('bar', Cons ('baz', Cons ('foo', Nil)))
```
-#### `sortBy :: (Ord b, Applicative f, Foldable f, Monoid (f a)) => (a -> b, f a) -> f a`
+#### `sortBy :: (Ord b, Applicative f, Foldable f, Monoid (f a)) => (a -> b, f a) -> f a`
Performs a [stable sort][] of the elements of the given structure,
using [`lte`](#lte) to compare the values produced by applying the
@@ -1149,20 +1237,20 @@ This function is derived from [`lte`](#lte), [`concat`](#concat),
See also [`sort`](#sort).
```javascript
-> sortBy(s => s.length, ['red', 'green', 'blue'])
+> sortBy (s => s.length, ['red', 'green', 'blue'])
['red', 'blue', 'green']
-> sortBy(s => s.length, ['black', 'white'])
+> sortBy (s => s.length, ['black', 'white'])
['black', 'white']
-> sortBy(s => s.length, ['white', 'black'])
+> sortBy (s => s.length, ['white', 'black'])
['white', 'black']
-> sortBy(s => s.length, Cons('red', Cons('green', Cons('blue', Nil))))
-Cons('red', Cons('blue', Cons('green', Nil)))
+> sortBy (s => s.length, Cons ('red', Cons ('green', Cons ('blue', Nil))))
+Cons ('red', Cons ('blue', Cons ('green', Nil)))
```
-#### `traverse :: (Applicative f, Traversable t) => (TypeRep f, a -> f b, t a) -> f (t b)`
+#### `traverse :: (Applicative f, Traversable t) => (TypeRep f, a -> f b, t a) -> f (t b)`
Function wrapper for [`fantasy-land/traverse`][].
@@ -1172,28 +1260,28 @@ built-in types: Array and Object.
See also [`sequence`](#sequence).
```javascript
-> traverse(Array, x => x, [[1, 2, 3], [4, 5]])
+> traverse (Array, x => x, [[1, 2, 3], [4, 5]])
[[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]]
-> traverse(Identity, x => Identity(x + 1), [1, 2, 3])
-Identity([2, 3, 4])
+> traverse (Identity, x => Identity (x + 1), [1, 2, 3])
+Identity ([2, 3, 4])
```
-#### `sequence :: (Applicative f, Traversable t) => (TypeRep f, t (f a)) -> f (t a)`
+#### `sequence :: (Applicative f, Traversable t) => (TypeRep f, t (f a)) -> f (t a)`
Inverts the given `t (f a)` to produce an `f (t a)`.
This function is derived from [`traverse`](#traverse).
```javascript
-> sequence(Array, Identity([1, 2, 3]))
-[Identity(1), Identity(2), Identity(3)]
+> sequence (Array, Identity ([1, 2, 3]))
+[Identity (1), Identity (2), Identity (3)]
-> sequence(Identity, [Identity(1), Identity(2), Identity(3)])
-Identity([1, 2, 3])
+> sequence (Identity, [Identity (1), Identity (2), Identity (3)])
+Identity ([1, 2, 3])
```
-#### `extend :: Extend w => (w a -> b, w a) -> w b`
+#### `extend :: Extend w => (w a -> b, w a) -> w b`
Function wrapper for [`fantasy-land/extend`][].
@@ -1201,43 +1289,43 @@ Function wrapper for [`fantasy-land/extend`][].
built-in types: Array and Function.
```javascript
-> extend(ss => ss.join(''), ['x', 'y', 'z'])
+> extend (ss => ss.join (''), ['x', 'y', 'z'])
['xyz', 'yz', 'z']
-> extend(f => f([3, 4]), reverse)([1, 2])
+> extend (f => f ([3, 4]), reverse) ([1, 2])
[4, 3, 2, 1]
```
-#### `duplicate :: Extend w => w a -> w (w a)`
+#### `duplicate :: Extend w => w a -> w (w a)`
Adds one level of nesting to a comonadic structure.
This function is derived from [`extend`](#extend).
```javascript
-> duplicate(Identity(1))
-Identity(Identity(1))
+> duplicate (Identity (1))
+Identity (Identity (1))
-> duplicate([1])
+> duplicate ([1])
[[1]]
-> duplicate([1, 2, 3])
+> duplicate ([1, 2, 3])
[[1, 2, 3], [2, 3], [3]]
-> duplicate(reverse)([1, 2])([3, 4])
+> duplicate (reverse) ([1, 2]) ([3, 4])
[4, 3, 2, 1]
```
-#### `extract :: Comonad w => w a -> a`
+#### `extract :: Comonad w => w a -> a`
Function wrapper for [`fantasy-land/extract`][].
```javascript
-> extract(Identity(42))
+> extract (Identity (42))
42
```
-#### `contramap :: Contravariant f => (b -> a, f a) -> f b`
+#### `contramap :: Contravariant f => (b -> a, f a) -> f b`
Function wrapper for [`fantasy-land/contramap`][].
@@ -1245,7 +1333,7 @@ Function wrapper for [`fantasy-land/contramap`][].
built-in types: Function.
```javascript
-> contramap(s => s.length, Math.sqrt)('Sanctuary')
+> contramap (s => s.length, Math.sqrt) ('Sanctuary')
3
```
diff --git a/index.js b/index.js
index a09685f..5ce2f62 100644
--- a/index.js
+++ b/index.js
@@ -285,7 +285,7 @@
};
}
- var version = '9.0.0'; // updated programmatically
+ var version = '10.0.0'; // updated programmatically
var keys = Object.keys (requirements);
var typeClass = TypeClass (
diff --git a/package.json b/package.json
index 88d246c..09b54eb 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "sanctuary-type-classes",
- "version": "9.0.0",
+ "version": "10.0.0",
"description": "Standard library for Fantasy Land",
"license": "MIT",
"repository": {