diff --git a/README.md b/README.md index 82e8b8a..f5ddd8e 100644 --- a/README.md +++ b/README.md @@ -18,42 +18,42 @@ This project provides: ## Type-class hierarchy
- Setoid   Semigroup   Foldable        Functor      Contravariant
-(equals)   (concat)   (reduce)         (map)        (contramap)
-    |         |           \         / | | | | \
-    |         |            \       /  | | | |  \
-    |         |             \     /   | | | |   \
-    |         |              \   /    | | | |    \
-    |         |               \ /     | | | |     \
-   Ord     Monoid         Traversable | | | |      \
-  (lte)    (empty)        (traverse)  / | | \       \
-                                     /  | |  \       \
-                                    /   / \   \       \
-                            Profunctor /   \ Bifunctor \
-                             (promap) /     \ (bimap)   \
-                                     /       \           \
-                                    /         \           \
-                                  Alt        Apply      Extend
-                                 (alt)        (ap)     (extend)
-                                  /           / \           \
-                                 /           /   \           \
-                                /           /     \           \
-                               /           /       \           \
-                              /           /         \           \
-                            Plus    Applicative    Chain      Comonad
-                           (zero)       (of)      (chain)    (extract)
-                              \         / \         / \
-                               \       /   \       /   \
-                                \     /     \     /     \
-                                 \   /       \   /       \
-                                  \ /         \ /         \
-                              Alternative    Monad     ChainRec
-                                                      (chainRec)
+ Setoid   Semigroupoid  Semigroup   Foldable        Functor      Contravariant
+(equals)    (compose)    (concat)   (reduce)         (map)        (contramap)
+    |           |           |           \         / | | | | \
+    |           |           |            \       /  | | | |  \
+    |           |           |             \     /   | | | |   \
+    |           |           |              \   /    | | | |    \
+    |           |           |               \ /     | | | |     \
+   Ord      Category     Monoid         Traversable | | | |      \
+  (lte)       (id)       (empty)        (traverse)  / | | \       \
+                                                   /  | |  \       \
+                                                  /   / \   \       \
+                                          Profunctor /   \ Bifunctor \
+                                           (promap) /     \ (bimap)   \
+                                                   /       \           \
+                                                  /         \           \
+                                                Alt        Apply      Extend
+                                               (alt)        (ap)     (extend)
+                                                /           / \           \
+                                               /           /   \           \
+                                              /           /     \           \
+                                             /           /       \           \
+                                            /           /         \           \
+                                          Plus    Applicative    Chain      Comonad
+                                         (zero)       (of)      (chain)    (extract)
+                                            \         / \         / \
+                                             \       /   \       /   \
+                                              \     /     \     /     \
+                                               \   /       \   /       \
+                                                \ /         \ /         \
+                                            Alternative    Monad     ChainRec
+                                                                    (chainRec)
 
## API -

TypeClass :: (String, Array TypeClass, a -> Boolean) -> TypeClass

+

TypeClass :: (String, Array TypeClass, a -> Boolean) -> TypeClass

The arguments are: @@ -89,7 +89,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][]. @@ -98,7 +98,7 @@ type-class constraints at run time. true ``` -

Ord :: TypeClass

+

Ord :: TypeClass

`TypeClass` value for [Ord][]. @@ -110,7 +110,31 @@ true false ``` -

Semigroup :: TypeClass

+

Semigroupoid :: TypeClass

+ +`TypeClass` value for [Semigroupoid][]. + +```javascript +> Semigroupoid.test(Math.sqrt) +true + +> Semigroupoid.test(0) +false +``` + +

Category :: TypeClass

+ +`TypeClass` value for [Category][]. + +```javascript +> Category.test(Math.sqrt) +true + +> Category.test(0) +false +``` + +

Semigroup :: TypeClass

`TypeClass` value for [Semigroup][]. @@ -122,7 +146,7 @@ true false ``` -

Monoid :: TypeClass

+

Monoid :: TypeClass

`TypeClass` value for [Monoid][]. @@ -134,7 +158,7 @@ true false ``` -

Functor :: TypeClass

+

Functor :: TypeClass

`TypeClass` value for [Functor][]. @@ -146,7 +170,7 @@ true false ``` -

Bifunctor :: TypeClass

+

Bifunctor :: TypeClass

`TypeClass` value for [Bifunctor][]. @@ -158,7 +182,7 @@ true false ``` -

Profunctor :: TypeClass

+

Profunctor :: TypeClass

`TypeClass` value for [Profunctor][]. @@ -170,7 +194,7 @@ true false ``` -

Apply :: TypeClass

+

Apply :: TypeClass

`TypeClass` value for [Apply][]. @@ -182,7 +206,7 @@ true false ``` -

Applicative :: TypeClass

+

Applicative :: TypeClass

`TypeClass` value for [Applicative][]. @@ -194,7 +218,7 @@ true false ``` -

Chain :: TypeClass

+

Chain :: TypeClass

`TypeClass` value for [Chain][]. @@ -206,7 +230,7 @@ true false ``` -

ChainRec :: TypeClass

+

ChainRec :: TypeClass

`TypeClass` value for [ChainRec][]. @@ -218,7 +242,7 @@ true false ``` -

Monad :: TypeClass

+

Monad :: TypeClass

`TypeClass` value for [Monad][]. @@ -230,7 +254,7 @@ true false ``` -

Alt :: TypeClass

+

Alt :: TypeClass

`TypeClass` value for [Alt][]. @@ -242,7 +266,7 @@ true false ``` -

Plus :: TypeClass

+

Plus :: TypeClass

`TypeClass` value for [Plus][]. @@ -254,7 +278,7 @@ true false ``` -

Alternative :: TypeClass

+

Alternative :: TypeClass

`TypeClass` value for [Alternative][]. @@ -266,7 +290,7 @@ true false ``` -

Foldable :: TypeClass

+

Foldable :: TypeClass

`TypeClass` value for [Foldable][]. @@ -278,7 +302,7 @@ true false ``` -

Traversable :: TypeClass

+

Traversable :: TypeClass

`TypeClass` value for [Traversable][]. @@ -290,7 +314,7 @@ true false ``` -

Extend :: TypeClass

+

Extend :: TypeClass

`TypeClass` value for [Extend][]. @@ -302,7 +326,7 @@ true false ``` -

Comonad :: TypeClass

+

Comonad :: TypeClass

`TypeClass` value for [Comonad][]. @@ -314,7 +338,7 @@ true false ``` -

Contravariant :: TypeClass

+

Contravariant :: TypeClass

`TypeClass` value for [Contravariant][]. @@ -326,7 +350,7 @@ true false ``` -

toString :: a -> String

+

toString :: a -> String

Returns a useful string representation of its argument. @@ -352,7 +376,7 @@ and Object. 'Cons(1, Cons(2, Cons(3, Nil)))' ``` -

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. @@ -381,7 +405,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`][] @@ -402,7 +426,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 @@ -428,7 +452,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`][] @@ -449,7 +473,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 @@ -470,7 +494,31 @@ false true ``` -

concat :: Semigroup a => (a, a) -> a

+

compose :: Semigroupoid c => (c j k, c i j) -> c i k

+ +Function wrapper for [`fantasy-land/compose`][]. + +`fantasy-land/compose` implementations are provided for the following +built-in types: Function. + +```javascript +> compose(Math.sqrt, x => x + 1)(99) +10 +``` + +

id :: Category c => TypeRep c -> c

+ +Function wrapper for [`fantasy-land/id`][]. + +`fantasy-land/id` implementations are provided for the following +built-in types: Function. + +```javascript +> id(Function)('foo') +'foo' +``` + +

concat :: Semigroup a => (a, a) -> a

Function wrapper for [`fantasy-land/concat`][]. @@ -491,7 +539,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`][]. @@ -512,7 +560,7 @@ built-in types: String, Array, and Object. Nil ``` -

map :: Functor f => (a -> b, f a) -> f b

+

map :: Functor f => (a -> b, f a) -> f b

Function wrapper for [`fantasy-land/map`][]. @@ -539,7 +587,7 @@ Nil Cons(1, Cons(2, Cons(3, 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`][]. @@ -548,7 +596,7 @@ Function wrapper for [`fantasy-land/bimap`][]. Tuple('FOO', 8) ``` -

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`][]. @@ -560,7 +608,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`][]. @@ -584,7 +632,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. @@ -601,7 +649,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. @@ -618,7 +666,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. @@ -635,7 +683,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. @@ -652,7 +700,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`][]. @@ -670,7 +718,7 @@ built-in types: Array and Function. Cons(42, 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`][]. @@ -688,7 +736,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. @@ -705,7 +753,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`][]. @@ -722,7 +770,7 @@ built-in types: Array. ['oo!', 'oo?', 'on!', 'on?', 'no!', 'no?', 'nn!', 'nn?'] ``` -

filter :: (Applicative f, Foldable f, Monoid (f a)) => (a -> Boolean, f a) -> f a

+

filter :: (Applicative f, Foldable f, Monoid (f a)) => (a -> Boolean, f a) -> f a

Filters its second argument in accordance with the given predicate. @@ -739,7 +787,7 @@ See also [`filterM`](#filterM). Cons(1, Cons(3, Nil)) ``` -

filterM :: (Alternative m, Monad m) => (a -> Boolean, m a) -> m a

+

filterM :: (Alternative m, Monad m) => (a -> Boolean, m a) -> m a

Filters its second argument in accordance with the given predicate. @@ -765,7 +813,7 @@ Nothing Just(1) ``` -

alt :: Alt f => (f a, f a) -> f a

+

alt :: Alt f => (f a, f a) -> f a

Function wrapper for [`fantasy-land/alt`][]. @@ -786,7 +834,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`][]. @@ -804,7 +852,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`][]. @@ -819,7 +867,7 @@ built-in types: Array and Object. 'foobarbaz' ``` -

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`][]. @@ -836,7 +884,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)`. @@ -850,7 +898,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`][]. @@ -862,7 +910,7 @@ built-in types: Array. [4] ``` -

extract :: Comonad w => w a -> a

+

extract :: Comonad w => w a -> a

Function wrapper for [`fantasy-land/extract`][]. @@ -871,7 +919,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`][]. @@ -888,6 +936,7 @@ built-in types: Function. [Applicative]: https://github.com/fantasyland/fantasy-land#applicative [Apply]: https://github.com/fantasyland/fantasy-land#apply [Bifunctor]: https://github.com/fantasyland/fantasy-land#bifunctor +[Category]: https://github.com/fantasyland/fantasy-land#category [Chain]: https://github.com/fantasyland/fantasy-land#chain [ChainRec]: https://github.com/fantasyland/fantasy-land#chainrec [Comonad]: https://github.com/fantasyland/fantasy-land#comonad @@ -902,6 +951,7 @@ built-in types: Function. [Plus]: https://github.com/fantasyland/fantasy-land#plus [Profunctor]: https://github.com/fantasyland/fantasy-land#profunctor [Semigroup]: https://github.com/fantasyland/fantasy-land#semigroup +[Semigroupoid]: https://github.com/fantasyland/fantasy-land#semigroupoid [Setoid]: https://github.com/fantasyland/fantasy-land#setoid [Traversable]: https://github.com/fantasyland/fantasy-land#traversable [`fantasy-land/alt`]: https://github.com/fantasyland/fantasy-land#alt-method @@ -909,12 +959,14 @@ built-in types: Function. [`fantasy-land/bimap`]: https://github.com/fantasyland/fantasy-land#bimap-method [`fantasy-land/chain`]: https://github.com/fantasyland/fantasy-land#chain-method [`fantasy-land/chainRec`]: https://github.com/fantasyland/fantasy-land#chainrec-method +[`fantasy-land/compose`]: https://github.com/fantasyland/fantasy-land#compose-method [`fantasy-land/concat`]: https://github.com/fantasyland/fantasy-land#concat-method [`fantasy-land/contramap`]: https://github.com/fantasyland/fantasy-land#contramap-method [`fantasy-land/empty`]: https://github.com/fantasyland/fantasy-land#empty-method [`fantasy-land/equals`]: https://github.com/fantasyland/fantasy-land#equals-method [`fantasy-land/extend`]: https://github.com/fantasyland/fantasy-land#extend-method [`fantasy-land/extract`]: https://github.com/fantasyland/fantasy-land#extract-method +[`fantasy-land/id`]: https://github.com/fantasyland/fantasy-land#id-method [`fantasy-land/lte`]: https://github.com/fantasyland/fantasy-land#lte-method [`fantasy-land/map`]: https://github.com/fantasyland/fantasy-land#map-method [`fantasy-land/of`]: https://github.com/fantasyland/fantasy-land#of-method diff --git a/package.json b/package.json index d60ca9b..4cf1b4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sanctuary-type-classes", - "version": "5.1.0", + "version": "5.2.0", "description": "Standard library for Fantasy Land", "license": "MIT", "repository": {