diff --git a/LICENSE b/LICENSE index ab65140..5d87459 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019 Sanctuary +Copyright (c) 2020 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 7b24049..9bff583 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: @@ -100,7 +100,7 @@ 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][]. @@ -109,7 +109,7 @@ type-class constraints at run time. true ``` -#### `Ord :: TypeClass` +#### `Ord :: TypeClass` `TypeClass` value for [Ord][]. @@ -121,7 +121,7 @@ true false ``` -#### `Semigroupoid :: TypeClass` +#### `Semigroupoid :: TypeClass` `TypeClass` value for [Semigroupoid][]. @@ -133,7 +133,7 @@ true false ``` -#### `Category :: TypeClass` +#### `Category :: TypeClass` `TypeClass` value for [Category][]. @@ -145,7 +145,7 @@ true false ``` -#### `Semigroup :: TypeClass` +#### `Semigroup :: TypeClass` `TypeClass` value for [Semigroup][]. @@ -157,7 +157,7 @@ true false ``` -#### `Monoid :: TypeClass` +#### `Monoid :: TypeClass` `TypeClass` value for [Monoid][]. @@ -169,7 +169,7 @@ true false ``` -#### `Group :: TypeClass` +#### `Group :: TypeClass` `TypeClass` value for [Group][]. @@ -181,7 +181,7 @@ true false ``` -#### `Filterable :: TypeClass` +#### `Filterable :: TypeClass` `TypeClass` value for [Filterable][]. @@ -193,7 +193,7 @@ true false ``` -#### `Functor :: TypeClass` +#### `Functor :: TypeClass` `TypeClass` value for [Functor][]. @@ -205,7 +205,7 @@ true false ``` -#### `Bifunctor :: TypeClass` +#### `Bifunctor :: TypeClass` `TypeClass` value for [Bifunctor][]. @@ -217,7 +217,7 @@ true false ``` -#### `Profunctor :: TypeClass` +#### `Profunctor :: TypeClass` `TypeClass` value for [Profunctor][]. @@ -229,7 +229,7 @@ true false ``` -#### `Apply :: TypeClass` +#### `Apply :: TypeClass` `TypeClass` value for [Apply][]. @@ -241,7 +241,7 @@ true false ``` -#### `Applicative :: TypeClass` +#### `Applicative :: TypeClass` `TypeClass` value for [Applicative][]. @@ -253,7 +253,7 @@ true false ``` -#### `Chain :: TypeClass` +#### `Chain :: TypeClass` `TypeClass` value for [Chain][]. @@ -265,7 +265,7 @@ true false ``` -#### `ChainRec :: TypeClass` +#### `ChainRec :: TypeClass` `TypeClass` value for [ChainRec][]. @@ -277,7 +277,7 @@ true false ``` -#### `Monad :: TypeClass` +#### `Monad :: TypeClass` `TypeClass` value for [Monad][]. @@ -289,7 +289,7 @@ true false ``` -#### `Alt :: TypeClass` +#### `Alt :: TypeClass` `TypeClass` value for [Alt][]. @@ -301,7 +301,7 @@ true false ``` -#### `Plus :: TypeClass` +#### `Plus :: TypeClass` `TypeClass` value for [Plus][]. @@ -313,7 +313,7 @@ true false ``` -#### `Alternative :: TypeClass` +#### `Alternative :: TypeClass` `TypeClass` value for [Alternative][]. @@ -325,7 +325,7 @@ true false ``` -#### `Foldable :: TypeClass` +#### `Foldable :: TypeClass` `TypeClass` value for [Foldable][]. @@ -337,7 +337,7 @@ true false ``` -#### `Traversable :: TypeClass` +#### `Traversable :: TypeClass` `TypeClass` value for [Traversable][]. @@ -349,7 +349,7 @@ true false ``` -#### `Extend :: TypeClass` +#### `Extend :: TypeClass` `TypeClass` value for [Extend][]. @@ -361,7 +361,7 @@ true false ``` -#### `Comonad :: TypeClass` +#### `Comonad :: TypeClass` `TypeClass` value for [Comonad][]. @@ -373,7 +373,7 @@ true false ``` -#### `Contravariant :: TypeClass` +#### `Contravariant :: TypeClass` `TypeClass` value for [Contravariant][]. @@ -385,7 +385,7 @@ true 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. @@ -414,7 +414,7 @@ true 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`][] @@ -435,7 +435,7 @@ true 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 @@ -461,7 +461,7 @@ true 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`][] @@ -482,7 +482,7 @@ false 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 @@ -503,7 +503,7 @@ false true ``` -#### `min :: Ord a => (a, a) -⁠> a` +#### `min :: Ord a => (a, a) -⁠> a` Returns the smaller of its two arguments. @@ -522,7 +522,7 @@ new Date ('1999-12-31') '10' ``` -#### `max :: Ord a => (a, a) -⁠> a` +#### `max :: Ord a => (a, a) -⁠> a` Returns the larger of its two arguments. @@ -541,7 +541,7 @@ new Date ('2000-01-01') '2' ``` -#### `clamp :: Ord a => (a, a, a) -⁠> a` +#### `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. @@ -559,7 +559,7 @@ This function is derived from [`min`](#min) and [`max`](#max). 'Z' ``` -#### `compose :: Semigroupoid c => (c j k, c i j) -⁠> c i k` +#### `compose :: Semigroupoid c => (c j k, c i j) -⁠> c i k` Function wrapper for [`fantasy-land/compose`][]. @@ -571,7 +571,7 @@ built-in types: Function. 10 ``` -#### `id :: Category c => TypeRep c -⁠> c` +#### `id :: Category c => TypeRep c -⁠> c` Function wrapper for [`fantasy-land/id`][]. @@ -583,7 +583,7 @@ built-in types: Function. 'foo' ``` -#### `concat :: Semigroup a => (a, a) -⁠> a` +#### `concat :: Semigroup a => (a, a) -⁠> a` Function wrapper for [`fantasy-land/concat`][]. @@ -604,7 +604,7 @@ built-in types: String, Array, and Object. 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`][]. @@ -625,7 +625,7 @@ built-in types: String, Array, and Object. Nil ``` -#### `invert :: Group g => g -⁠> g` +#### `invert :: Group g => g -⁠> g` Function wrapper for [`fantasy-land/invert`][]. @@ -634,7 +634,7 @@ Function wrapper for [`fantasy-land/invert`][]. 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. @@ -664,7 +664,7 @@ Nothing 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. @@ -690,7 +690,7 @@ Just (0) Nothing ``` -#### `map :: Functor f => (a -⁠> b, f a) -⁠> f b` +#### `map :: Functor f => (a -⁠> b, f a) -⁠> f b` Function wrapper for [`fantasy-land/map`][]. @@ -717,7 +717,7 @@ 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. @@ -737,7 +737,7 @@ This function is derived from [`map`](#map). 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`][]. @@ -746,7 +746,7 @@ Function wrapper for [`fantasy-land/bimap`][]. 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. @@ -755,7 +755,7 @@ Maps the given function over the left side of a Bifunctor. 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`][]. @@ -767,7 +767,7 @@ built-in types: Function. 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`][]. @@ -791,7 +791,7 @@ Identity (8) 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. @@ -808,7 +808,7 @@ See also [`lift3`](#lift3). 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. @@ -834,7 +834,7 @@ See also [`lift2`](#lift2). 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. @@ -851,7 +851,7 @@ See also [`apSecond`](#apSecond). 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. @@ -868,7 +868,7 @@ See also [`apFirst`](#apFirst). Identity (2) ``` -#### `of :: Applicative f => (TypeRep f, a) -⁠> f a` +#### `of :: Applicative f => (TypeRep f, a) -⁠> f a` Function wrapper for [`fantasy-land/of`][]. @@ -886,7 +886,7 @@ built-in types: Array and Function. 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. @@ -902,7 +902,7 @@ See also [`prepend`](#prepend). 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. @@ -918,7 +918,7 @@ See also [`append`](#append). 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,7 +939,7 @@ Cons (1, Cons (3, Nil)) '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. @@ -956,7 +956,7 @@ This function is derived from [`chain`](#chain). 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`][]. @@ -973,7 +973,7 @@ built-in types: Array. ['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`][]. @@ -994,7 +994,7 @@ Just (1) Just (2) ``` -#### `zero :: Plus f => TypeRep f -⁠> f a` +#### `zero :: Plus f => TypeRep f -⁠> f a` Function wrapper for [`fantasy-land/zero`][]. @@ -1012,7 +1012,7 @@ built-in types: Array and Object. 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`][]. @@ -1027,7 +1027,7 @@ built-in types: Array and Object. 'foobarbaz' ``` -#### `size :: Foldable f => f a -⁠> Integer` +#### `size :: Foldable f => f a -⁠> Integer` Returns the number of elements of the given structure. @@ -1047,7 +1047,7 @@ This function is derived from [`reduce`](#reduce). 3 ``` -#### `all :: Foldable f => (a -⁠> Boolean, 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. @@ -1067,7 +1067,7 @@ true false ``` -#### `any :: Foldable f => (a -⁠> Boolean, f a) -⁠> Boolean` +#### `any :: Foldable f => (a -⁠> Boolean, f a) -⁠> Boolean` Returns `true` if any element of the structure satisfies the predicate; `false` otherwise. @@ -1087,7 +1087,7 @@ true true ``` -#### `none :: Foldable f => (a -⁠> Boolean, f a) -⁠> Boolean` +#### `none :: Foldable f => (a -⁠> Boolean, f a) -⁠> Boolean` Returns `true` if none of the elements of the structure satisfies the predicate; `false` otherwise. @@ -1105,7 +1105,7 @@ true false ``` -#### `elem :: (Setoid a, Foldable f) => (a, f a) -⁠> Boolean` +#### `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. @@ -1136,7 +1136,35 @@ false false ``` -#### `foldMap :: (Monoid m, Foldable f) => (TypeRep m, a -⁠> m, f a) -⁠> m` +#### `intercalate :: (Monoid m, Foldable f) => (m, f m) -⁠> m` + +Concatenates the elements of the given structure, separating each pair +of adjacent elements with the given separator. + +This function is derived from [`concat`](#concat), [`empty`](#empty), +and [`reduce`](#reduce). + +```javascript +> intercalate (', ', []) +'' + +> intercalate (', ', ['foo', 'bar', 'baz']) +'foo, bar, baz' + +> intercalate (', ', Nil) +'' + +> intercalate (', ', Cons ('foo', Cons ('bar', Cons ('baz', Nil)))) +'foo, bar, baz' + +> intercalate ([0, 0, 0], []) +[] + +> intercalate ([0, 0, 0], [[1], [2, 3], [4, 5, 6], [7, 8], [9]]) +[1, 0, 0, 0, 2, 3, 0, 0, 0, 4, 5, 6, 0, 0, 0, 7, 8, 0, 0, 0, 9] +``` + +#### `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. @@ -1149,7 +1177,7 @@ and [`reduce`](#reduce). '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. @@ -1164,7 +1192,7 @@ This function is derived from [`concat`](#concat), [`empty`](#empty), 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. @@ -1185,7 +1213,7 @@ See also [`sortBy`](#sortBy). 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 @@ -1210,7 +1238,7 @@ See also [`sort`](#sort). 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`][]. @@ -1227,7 +1255,7 @@ See also [`sequence`](#sequence). 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)`. @@ -1241,7 +1269,7 @@ This function is derived from [`traverse`](#traverse). 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`][]. @@ -1256,7 +1284,7 @@ built-in types: Array and Function. [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. @@ -1276,7 +1304,7 @@ Identity (Identity (1)) [4, 3, 2, 1] ``` -#### `extract :: Comonad w => w a -⁠> a` +#### `extract :: Comonad w => w a -⁠> a` Function wrapper for [`fantasy-land/extract`][]. @@ -1285,7 +1313,7 @@ Function wrapper for [`fantasy-land/extract`][]. 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`][]. diff --git a/index.js b/index.js index faa84e8..318c335 100644 --- a/index.js +++ b/index.js @@ -285,7 +285,7 @@ }; } - var version = '12.0.0'; // updated programmatically + var version = '12.1.0'; // updated programmatically var keys = Object.keys (requirements); var typeClass = TypeClass ( diff --git a/package.json b/package.json index 3de7882..2fa8fb0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sanctuary-type-classes", - "version": "12.0.0", + "version": "12.1.0", "description": "Standard library for Fantasy Land", "license": "MIT", "repository": {