diff --git a/README.md b/README.md index da6f2dc3..0b767a94 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ const S = create({checkTypes: checkTypes, env: env}); ## API -

create :: { checkTypes :: Boolean, env :: Array Type } -> Module

+

create :: { checkTypes :: Boolean, env :: Array Type } -> Module

Takes an options record and returns a Sanctuary module. `checkTypes` specifies whether to enable type checking. The module's polymorphic @@ -184,14 +184,14 @@ const S = create({ See also [`env`](#env). -

env :: Array Type

+

env :: Array Type

The default environment, which may be used as is or as the basis of a custom environment in conjunction with [`create`](#create). ### Classify -

type :: a -> String

+

type :: a -> String

Takes a value, `x`, of any type and returns its type identifier. If `x` has a `'@@type'` property whose value is a string, `x['@@type']` @@ -210,7 +210,7 @@ is defined. 'Array' ``` -

is :: TypeRep a -> b -> Boolean

+

is :: TypeRep a -> b -> Boolean

Takes a [type representative](#type-representatives) and a value of any type and returns `true` if the given value is of the specified @@ -229,7 +229,7 @@ false ### Combinator -

I :: a -> a

+

I :: a -> a

The I combinator. Returns its argument. Equivalent to Haskell's `id` function. @@ -239,7 +239,7 @@ function. 'foo' ``` -

K :: a -> b -> a

+

K :: a -> b -> a

The K combinator. Takes two values and returns the first. Equivalent to Haskell's `const` function. @@ -252,7 +252,7 @@ Haskell's `const` function. [42, 42, 42, 42, 42] ``` -

A :: (a -> b) -> a -> b

+

A :: (a -> b) -> a -> b

The A combinator. Takes a function and a value, and returns the result of applying the function to the value. Equivalent to Haskell's `($)` @@ -266,7 +266,7 @@ function. [101, 10] ``` -

T :: a -> (a -> b) -> b

+

T :: a -> (a -> b) -> b

The T ([thrush][]) combinator. Takes a value and a function, and returns the result of applying the function to the value. Equivalent to Haskell's @@ -280,7 +280,7 @@ the result of applying the function to the value. Equivalent to Haskell's [101, 10] ``` -

C :: (a -> b -> c) -> b -> a -> c

+

C :: (a -> b -> c) -> b -> a -> c

The C combinator. Takes a curried binary function and two values, and returns the result of applying the function to the values in reverse. @@ -298,7 +298,7 @@ functions. [3, 4, 2] ``` -

B :: (b -> c) -> (a -> b) -> a -> c

+

B :: (b -> c) -> (a -> b) -> a -> c

The B combinator. Takes two functions and a value, and returns the result of applying the first function to the result of applying the @@ -310,7 +310,7 @@ second to the value. Equivalent to [`compose`](#compose) and Haskell's 10 ``` -

S :: (a -> b -> c) -> (a -> b) -> a -> c

+

S :: (a -> b -> c) -> (a -> b) -> a -> c

The S combinator. Takes a curried binary function, a unary function, and a value, and returns the result of applying the binary function to: @@ -325,7 +325,7 @@ and a value, and returns the result of applying the binary function to: ### Function -

flip :: ((a, b) -> c) -> b -> a -> c

+

flip :: ((a, b) -> c) -> b -> a -> c

Takes a binary function and two values and returns the result of applying the function - with its argument order reversed - to the @@ -339,7 +339,7 @@ See also [`C`](#C). [1, 4, 9, 16, 25] ``` -

lift :: Functor f => (a -> b) -> f a -> f b

+

lift :: Functor f => (a -> b) -> f a -> f b

Promotes a unary function to a function which operates on a [Functor][]. @@ -351,7 +351,7 @@ Just(3) Nothing() ``` -

lift2 :: Apply f => (a -> b -> c) -> f a -> f b -> f c

+

lift2 :: Apply f => (a -> b -> c) -> f a -> f b -> f c

Promotes a binary function to a function which operates on two [Apply][]s. @@ -370,7 +370,7 @@ Just(true) Just(false) ``` -

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

Promotes a ternary function to a function which operates on three [Apply][]s. @@ -385,7 +385,7 @@ Nothing() ### Composition -

compose :: (b -> c) -> (a -> b) -> a -> c

+

compose :: (b -> c) -> (a -> b) -> a -> c

Takes two functions assumed to be unary and a value of any type, and returns the result of applying the first function to the result @@ -401,7 +401,7 @@ See also [`B`](#B) and [`pipe`](#pipe). 10 ``` -

pipe :: [(a -> b), (b -> c), ..., (m -> n)] -> a -> n

+

pipe :: [(a -> b), (b -> c), ..., (m -> n)] -> a -> n

Takes an array of functions assumed to be unary and a value of any type, and returns the result of applying the sequence of transformations to @@ -417,7 +417,7 @@ See also [`meld`](#meld). 9 ``` -

meld :: [** -> *] -> (* -> * -> ... -> *)

+

meld :: [** -> *] -> (* -> * -> ... -> *)

Takes an array of non-nullary functions and returns a curried function whose arity is one greater than the sum of the arities of the given @@ -452,15 +452,15 @@ either a Just whose value is of type `a` or a Nothing (with no value). The Maybe type satisfies the [Monoid][], [Monad][], [Traversable][], and [Extend][] specifications. -

MaybeType :: Type -> Type

+

MaybeType :: Type -> Type

A [`UnaryType`][UnaryType] for use with [sanctuary-def][]. -

Maybe :: TypeRep Maybe

+

Maybe :: TypeRep Maybe

The [type representative](#type-representatives) for the Maybe type. -

Maybe.empty :: -> Maybe a

+

Maybe.empty :: -> Maybe a

Returns a Nothing. @@ -469,7 +469,7 @@ Returns a Nothing. Nothing() ``` -

Maybe.of :: a -> Maybe a

+

Maybe.of :: a -> Maybe a

Takes a value of any type and returns a Just with the given value. @@ -478,11 +478,11 @@ Takes a value of any type and returns a Just with the given value. Just(42) ``` -

Maybe#@@type :: String

+

Maybe#@@type :: String

Maybe type identifier, `'sanctuary/Maybe'`. -

Maybe#isNothing :: Boolean

+

Maybe#isNothing :: Boolean

`true` if `this` is a Nothing; `false` if `this` is a Just. @@ -494,7 +494,7 @@ true false ``` -

Maybe#isJust :: Boolean

+

Maybe#isJust :: Boolean

`true` if `this` is a Just; `false` if `this` is a Nothing. @@ -506,7 +506,7 @@ true false ``` -

Maybe#ap :: Maybe (a -> b) ~> Maybe a -> Maybe b

+

Maybe#ap :: Maybe (a -> b) ~> Maybe a -> Maybe b

Takes a value of type `Maybe a` and returns a Nothing unless `this` is a Just *and* the argument is a Just, in which case it returns a @@ -524,7 +524,7 @@ Nothing() Just(43) ``` -

Maybe#chain :: Maybe a ~> (a -> Maybe b) -> Maybe b

+

Maybe#chain :: Maybe a ~> (a -> Maybe b) -> Maybe b

Takes a function and returns `this` if `this` is a Nothing; otherwise it returns the result of applying the function to this Just's value. @@ -540,7 +540,7 @@ Nothing() Just(12.34) ``` -

Maybe#concat :: Semigroup a => Maybe a ~> Maybe a -> Maybe a

+

Maybe#concat :: Semigroup a => Maybe a ~> Maybe a -> Maybe a

Returns the result of concatenating two Maybe values of the same type. `a` must have a [Semigroup][] (indicated by the presence of a `concat` @@ -569,7 +569,7 @@ Just([1, 2, 3]) Just([1, 2, 3]) ``` -

Maybe#empty :: Maybe a ~> Maybe a

+

Maybe#empty :: Maybe a ~> Maybe a

Returns a Nothing. @@ -578,7 +578,7 @@ Returns a Nothing. Nothing() ``` -

Maybe#equals :: Maybe a ~> b -> Boolean

+

Maybe#equals :: Maybe a ~> b -> Boolean

Takes a value of any type and returns `true` if: @@ -604,7 +604,7 @@ false false ``` -

Maybe#extend :: Maybe a ~> (Maybe a -> a) -> Maybe a

+

Maybe#extend :: Maybe a ~> (Maybe a -> a) -> Maybe a

Takes a function and returns `this` if `this` is a Nothing; otherwise it returns a Just whose value is the result of applying the function to @@ -618,7 +618,7 @@ Nothing() Just(43) ``` -

Maybe#filter :: Maybe a ~> (a -> Boolean) -> Maybe a

+

Maybe#filter :: Maybe a ~> (a -> Boolean) -> Maybe a

Takes a predicate and returns `this` if `this` is a Just whose value satisfies the predicate; Nothing otherwise. @@ -631,7 +631,7 @@ Just(42) Nothing() ``` -

Maybe#map :: Maybe a ~> (a -> b) -> Maybe b

+

Maybe#map :: Maybe a ~> (a -> b) -> Maybe b

Takes a function and returns `this` if `this` is a Nothing; otherwise it returns a Just whose value is the result of applying the function to @@ -645,7 +645,7 @@ Nothing() Just(6) ``` -

Maybe#of :: Maybe a ~> b -> Maybe b

+

Maybe#of :: Maybe a ~> b -> Maybe b

Takes a value of any type and returns a Just with the given value. @@ -654,7 +654,7 @@ Takes a value of any type and returns a Just with the given value. Just(42) ``` -

Maybe#reduce :: Maybe a ~> ((b, a) -> b) -> b -> b

+

Maybe#reduce :: Maybe a ~> ((b, a) -> b) -> b -> b

Takes a function and an initial value of any type, and returns: @@ -671,7 +671,7 @@ Takes a function and an initial value of any type, and returns: 15 ``` -

Maybe#sequence :: Applicative f => Maybe (f a) ~> (a -> f a) -> f (Maybe a)

+

Maybe#sequence :: Applicative f => Maybe (f a) ~> (a -> f a) -> f (Maybe a)

Evaluates an applicative action contained within the Maybe, resulting in: @@ -690,7 +690,7 @@ Right(Just(42)) Left('Cannot divide by zero') ``` -

Maybe#toBoolean :: Maybe a ~> Boolean

+

Maybe#toBoolean :: Maybe a ~> Boolean

Returns `false` if `this` is a Nothing; `true` if `this` is a Just. @@ -702,7 +702,7 @@ false true ``` -

Maybe#toString :: Maybe a ~> String

+

Maybe#toString :: Maybe a ~> String

Returns the string representation of the Maybe. @@ -714,7 +714,7 @@ Returns the string representation of the Maybe. 'Just([1, 2, 3])' ``` -

Maybe#inspect :: Maybe a ~> String

+

Maybe#inspect :: Maybe a ~> String

Returns the string representation of the Maybe. This method is used by `util.inspect` and the REPL to format a Maybe for display. @@ -729,7 +729,7 @@ See also [`Maybe#toString`](#Maybe.prototype.toString). 'Just([1, 2, 3])' ``` -

Nothing :: -> Maybe a

+

Nothing :: -> Maybe a

Returns a Nothing. @@ -738,7 +738,7 @@ Returns a Nothing. Nothing() ``` -

Just :: a -> Maybe a

+

Just :: a -> Maybe a

Takes a value of any type and returns a Just with the given value. @@ -747,7 +747,7 @@ Takes a value of any type and returns a Just with the given value. Just(42) ``` -

isNothing :: Maybe a -> Boolean

+

isNothing :: Maybe a -> Boolean

Returns `true` if the given Maybe is a Nothing; `false` if it is a Just. @@ -759,7 +759,7 @@ true false ``` -

isJust :: Maybe a -> Boolean

+

isJust :: Maybe a -> Boolean

Returns `true` if the given Maybe is a Just; `false` if it is a Nothing. @@ -771,7 +771,7 @@ true false ``` -

fromMaybe :: a -> Maybe a -> a

+

fromMaybe :: a -> Maybe a -> a

Takes a default value and a Maybe, and returns the Maybe's value if the Maybe is a Just; the default value otherwise. @@ -786,7 +786,7 @@ See also [`maybeToNullable`](#maybeToNullable). 0 ``` -

maybeToNullable :: Maybe a -> Nullable a

+

maybeToNullable :: Maybe a -> Nullable a

Returns the given Maybe's value if the Maybe is a Just; `null` otherwise. [Nullable][] is defined in sanctuary-def. @@ -801,7 +801,7 @@ See also [`fromMaybe`](#fromMaybe). null ``` -

toMaybe :: a? -> Maybe a

+

toMaybe :: a? -> Maybe a

Takes a value and returns Nothing if the value is null or undefined; Just the value otherwise. @@ -814,7 +814,7 @@ Nothing() Just(42) ``` -

maybe :: b -> (a -> b) -> Maybe a -> b

+

maybe :: b -> (a -> b) -> Maybe a -> b

Takes a value of any type, a function, and a Maybe. If the Maybe is a Just, the return value is the result of applying the function to @@ -828,7 +828,7 @@ the Just's value. Otherwise, the first argument is returned. 0 ``` -

justs :: Array (Maybe a) -> Array a

+

justs :: Array (Maybe a) -> Array a

Takes an array of Maybes and returns an array containing each Just's value. Equivalent to Haskell's `catMaybes` function. @@ -840,7 +840,7 @@ See also [`lefts`](#lefts) and [`rights`](#rights). ['foo', 'baz'] ``` -

mapMaybe :: (a -> Maybe b) -> Array a -> Array b

+

mapMaybe :: (a -> Maybe b) -> Array a -> Array b

Takes a function and an array, applies the function to each element of the array, and returns an array of "successful" results. If the result of @@ -855,7 +855,7 @@ In general terms, `mapMaybe` filters an array while mapping over it. [1, 4] ``` -

encase :: (a -> b) -> a -> Maybe b

+

encase :: (a -> b) -> a -> Maybe b

Takes a unary function `f` which may throw and a value `x` of any type, and applies `f` to `x` inside a `try` block. If an exception is caught, @@ -872,27 +872,27 @@ Just(2) Nothing() ``` -

encase2 :: (a -> b -> c) -> a -> b -> Maybe c

+

encase2 :: (a -> b -> c) -> a -> b -> Maybe c

Binary version of [`encase`](#encase). See also [`encase2_`](#encase2_). -

encase2_ :: ((a, b) -> c) -> a -> b -> Maybe c

+

encase2_ :: ((a, b) -> c) -> a -> b -> Maybe c

Version of [`encase2`](#encase2) accepting uncurried functions. -

encase3 :: (a -> b -> c -> d) -> a -> b -> c -> Maybe d

+

encase3 :: (a -> b -> c -> d) -> a -> b -> c -> Maybe d

Ternary version of [`encase`](#encase). See also [`encase3_`](#encase3_). -

encase3_ :: ((a, b, c) -> d) -> a -> b -> c -> Maybe d

+

encase3_ :: ((a, b, c) -> d) -> a -> b -> c -> Maybe d

Version of [`encase3`](#encase3) accepting uncurried functions. -

maybeToEither :: a -> Maybe b -> Either a b

+

maybeToEither :: a -> Maybe b -> Either a b

Converts a Maybe to an Either. A Nothing becomes a Left (containing the first argument); a Just becomes a Right. @@ -916,15 +916,15 @@ value is of type `b`. The Either type satisfies the [Semigroup][], [Monad][], [Traversable][], and [Extend][] specifications. -

EitherType :: Type -> Type -> Type

+

EitherType :: Type -> Type -> Type

A [`BinaryType`][BinaryType] for use with [sanctuary-def][]. -

Either :: TypeRep Either

+

Either :: TypeRep Either

The [type representative](#type-representatives) for the Either type. -

Either.of :: b -> Either a b

+

Either.of :: b -> Either a b

Takes a value of any type and returns a Right with the given value. @@ -933,11 +933,11 @@ Takes a value of any type and returns a Right with the given value. Right(42) ``` -

Either#@@type :: String

+

Either#@@type :: String

Either type identifier, `'sanctuary/Either'`. -

Either#isLeft :: Boolean

+

Either#isLeft :: Boolean

`true` if `this` is a Left; `false` if `this` is a Right. @@ -949,7 +949,7 @@ true false ``` -

Either#isRight :: Boolean

+

Either#isRight :: Boolean

`true` if `this` is a Right; `false` if `this` is a Left. @@ -961,7 +961,7 @@ true false ``` -

Either#ap :: Either a (b -> c) ~> Either a b -> Either a c

+

Either#ap :: Either a (b -> c) ~> Either a b -> Either a c

Takes a value of type `Either a b` and returns a Left unless `this` is a Right *and* the argument is a Right, in which case it returns @@ -979,7 +979,7 @@ Left('Cannot divide by zero') Right(43) ``` -

Either#chain :: Either a b ~> (b -> Either a c) -> Either a c

+

Either#chain :: Either a b ~> (b -> Either a c) -> Either a c

Takes a function and returns `this` if `this` is a Left; otherwise it returns the result of applying the function to this Right's value. @@ -1000,7 +1000,7 @@ Left('Cannot represent square root of negative number') Right(5) ``` -

Either#concat :: (Semigroup a, Semigroup b) => Either a b ~> Either a b -> Either a b

+

Either#concat :: (Semigroup a, Semigroup b) => Either a b ~> Either a b -> Either a b

Returns the result of concatenating two Either values of the same type. `a` must have a [Semigroup][] (indicated by the presence of a `concat` @@ -1030,7 +1030,7 @@ Right([1, 2, 3]) Right([1, 2, 3]) ``` -

Either#equals :: Either a b ~> c -> Boolean

+

Either#equals :: Either a b ~> c -> Boolean

Takes a value of any type and returns `true` if: @@ -1051,7 +1051,7 @@ false false ``` -

Either#extend :: Either a b ~> (Either a b -> b) -> Either a b

+

Either#extend :: Either a b ~> (Either a b -> b) -> Either a b

Takes a function and returns `this` if `this` is a Left; otherwise it returns a Right whose value is the result of applying the function to @@ -1065,7 +1065,7 @@ Left('Cannot divide by zero') Right(43) ``` -

Either#map :: Either a b ~> (b -> c) -> Either a c

+

Either#map :: Either a b ~> (b -> c) -> Either a c

Takes a function and returns `this` if `this` is a Left; otherwise it returns a Right whose value is the result of applying the function to @@ -1079,7 +1079,7 @@ Left('Cannot divide by zero') Right(6) ``` -

Either#of :: Either a b ~> c -> Either a c

+

Either#of :: Either a b ~> c -> Either a c

Takes a value of any type and returns a Right with the given value. @@ -1088,7 +1088,7 @@ Takes a value of any type and returns a Right with the given value. Right(42) ``` -

Either#reduce :: Either a b ~> ((c, b) -> c) -> c -> c

+

Either#reduce :: Either a b ~> ((c, b) -> c) -> c -> c

Takes a function and an initial value of any type, and returns: @@ -1105,7 +1105,7 @@ Takes a function and an initial value of any type, and returns: [42, 5] ``` -

Either#sequence :: Applicative f => Either a (f b) ~> (b -> f b) -> f (Either a b)

+

Either#sequence :: Applicative f => Either a (f b) ~> (b -> f b) -> f (Either a b)

Evaluates an applicative action contained within the Either, resulting in: @@ -1125,7 +1125,7 @@ Just(Right(42)) Nothing() ``` -

Either#toBoolean :: Either a b ~> Boolean

+

Either#toBoolean :: Either a b ~> Boolean

Returns `false` if `this` is a Left; `true` if `this` is a Right. @@ -1137,7 +1137,7 @@ false true ``` -

Either#toString :: Either a b ~> String

+

Either#toString :: Either a b ~> String

Returns the string representation of the Either. @@ -1149,7 +1149,7 @@ Returns the string representation of the Either. 'Right([1, 2, 3])' ``` -

Either#inspect :: Either a b ~> String

+

Either#inspect :: Either a b ~> String

Returns the string representation of the Either. This method is used by `util.inspect` and the REPL to format a Either for display. @@ -1164,7 +1164,7 @@ See also [`Either#toString`](#Either.prototype.toString). 'Right([1, 2, 3])' ``` -

Left :: a -> Either a b

+

Left :: a -> Either a b

Takes a value of any type and returns a Left with the given value. @@ -1173,7 +1173,7 @@ Takes a value of any type and returns a Left with the given value. Left('Cannot divide by zero') ``` -

Right :: b -> Either a b

+

Right :: b -> Either a b

Takes a value of any type and returns a Right with the given value. @@ -1182,7 +1182,7 @@ Takes a value of any type and returns a Right with the given value. Right(42) ``` -

isLeft :: Either a b -> Boolean

+

isLeft :: Either a b -> Boolean

Returns `true` if the given Either is a Left; `false` if it is a Right. @@ -1194,7 +1194,7 @@ true false ``` -

isRight :: Either a b -> Boolean

+

isRight :: Either a b -> Boolean

Returns `true` if the given Either is a Right; `false` if it is a Left. @@ -1206,7 +1206,7 @@ true false ``` -

either :: (a -> c) -> (b -> c) -> Either a b -> c

+

either :: (a -> c) -> (b -> c) -> Either a b -> c

Takes two functions and an Either, and returns the result of applying the first function to the Left's value, if the Either @@ -1221,7 +1221,7 @@ Right's value, if the Either is a Right. '42' ``` -

lefts :: Array (Either a b) -> Array a

+

lefts :: Array (Either a b) -> Array a

Takes an array of Eithers and returns an array containing each Left's value. @@ -1233,7 +1233,7 @@ See also [`rights`](#rights). ['foo', 'bar'] ``` -

rights :: Array (Either a b) -> Array b

+

rights :: Array (Either a b) -> Array b

Takes an array of Eithers and returns an array containing each Right's value. @@ -1245,7 +1245,7 @@ See also [`lefts`](#lefts). [20, 10] ``` -

encaseEither :: (Error -> l) -> (a -> r) -> a -> Either l r

+

encaseEither :: (Error -> l) -> (a -> r) -> a -> Either l r

Takes two unary functions, `f` and `g`, the second of which may throw, and a value `x` of any type. Applies `g` to `x` inside a `try` block. @@ -1266,29 +1266,29 @@ Left(new SyntaxError('Unexpected end of input')) Left('Unexpected end of input') ``` -

encaseEither2 :: (Error -> l) -> (a -> b -> r) -> a -> b -> Either l r

+

encaseEither2 :: (Error -> l) -> (a -> b -> r) -> a -> b -> Either l r

Binary version of [`encaseEither`](#encaseEither). See also [`encaseEither2_`](#encaseEither2_). -

encaseEither2_ :: (Error -> l) -> ((a, b) -> r) -> a -> b -> Either l r

+

encaseEither2_ :: (Error -> l) -> ((a, b) -> r) -> a -> b -> Either l r

Version of [`encaseEither2`](#encaseEither2) accepting uncurried functions. -

encaseEither3 :: (Error -> l) -> (a -> b -> c -> r) -> a -> b -> c -> Either l r

+

encaseEither3 :: (Error -> l) -> (a -> b -> c -> r) -> a -> b -> c -> Either l r

Ternary version of [`encaseEither`](#encaseEither). See also [`encaseEither3_`](#encaseEither3_). -

encaseEither3_ :: (Error -> l) -> ((a, b, c) -> r) -> a -> b -> c -> Either l r

+

encaseEither3_ :: (Error -> l) -> ((a, b, c) -> r) -> a -> b -> c -> Either l r

Version of [`encaseEither3`](#encaseEither3) accepting uncurried functions. -

eitherToMaybe :: Either a b -> Maybe b

+

eitherToMaybe :: Either a b -> Maybe b

Converts an Either to a Maybe. A Left becomes a Nothing; a Right becomes a Just. @@ -1305,7 +1305,7 @@ Just(42) ### Alternative -

and :: Alternative a => a -> a -> a

+

and :: Alternative a => a -> a -> a

Takes two values of the same type and returns the second value if the first is "true"; the first value otherwise. An array is @@ -1321,7 +1321,7 @@ Just(2) Nothing() ``` -

or :: Alternative a => a -> a -> a

+

or :: Alternative a => a -> a -> a

Takes two values of the same type and returns the first value if it is "true"; the second value otherwise. An array is considered "true" @@ -1336,7 +1336,7 @@ Just(1) Just(3) ``` -

xor :: (Alternative a, Monoid a) => a -> a -> a

+

xor :: (Alternative a, Monoid a) => a -> a -> a

Takes two values of the same type and returns the "true" value if one value is "true" and the other is "false"; otherwise it @@ -1355,7 +1355,7 @@ Nothing() ### Logic -

not :: Boolean -> Boolean

+

not :: Boolean -> Boolean

Takes a Boolean and returns the negation of that value (`false` for `true`; `true` for `false`). @@ -1368,7 +1368,7 @@ false true ``` -

ifElse :: (a -> Boolean) -> (a -> b) -> (a -> b) -> a -> b

+

ifElse :: (a -> Boolean) -> (a -> b) -> (a -> b) -> a -> b

Takes a unary predicate, a unary "if" function, a unary "else" function, and a value of any type, and returns the result of @@ -1384,7 +1384,7 @@ value otherwise. 4 ``` -

allPass :: Array (a -> Boolean) -> a -> Boolean

+

allPass :: Array (a -> Boolean) -> a -> Boolean

Takes an array of unary predicates and a value of any type and returns `true` if all the predicates pass; `false` otherwise. @@ -1399,7 +1399,7 @@ true false ``` -

anyPass :: Array (a -> Boolean) -> a -> Boolean

+

anyPass :: Array (a -> Boolean) -> a -> Boolean

Takes an array of unary predicates and a value of any type and returns `true` if any of the predicates pass; `false` otherwise. @@ -1422,7 +1422,7 @@ properties greater than or equal to zero, such as `[1, 2, 3]` and `[a]` is the notation used to represent a List of values of type `a`. -

concat :: Semigroup a => a -> a -> a

+

concat :: Semigroup a => a -> a -> a

Concatenates two (homogeneous) arrays, two strings, or two values of any other type which satisfies the [Semigroup][] specification. @@ -1438,7 +1438,7 @@ other type which satisfies the [Semigroup][] specification. S.Just('foobar') ``` -

slice :: Integer -> Integer -> [a] -> Maybe [a]

+

slice :: Integer -> Integer -> [a] -> Maybe [a]

Returns Just a list containing the elements from the supplied list from a beginning index (inclusive) to an end index (exclusive). @@ -1467,7 +1467,7 @@ Nothing() Just('nana') ``` -

at :: Integer -> [a] -> Maybe a

+

at :: Integer -> [a] -> Maybe a

Takes an index and a list and returns Just the element of the list at the index if the index is within the list's bounds; Nothing otherwise. @@ -1484,7 +1484,7 @@ Nothing() Just('d') ``` -

head :: [a] -> Maybe a

+

head :: [a] -> Maybe a

Takes a list and returns Just the first element of the list if the list contains at least one element; Nothing if the list is empty. @@ -1497,7 +1497,7 @@ Just(1) Nothing() ``` -

last :: [a] -> Maybe a

+

last :: [a] -> Maybe a

Takes a list and returns Just the last element of the list if the list contains at least one element; Nothing if the list is empty. @@ -1510,7 +1510,7 @@ Just(3) Nothing() ``` -

tail :: [a] -> Maybe [a]

+

tail :: [a] -> Maybe [a]

Takes a list and returns Just a list containing all but the first of the list's elements if the list contains at least one element; @@ -1524,7 +1524,7 @@ Just([2, 3]) Nothing() ``` -

init :: [a] -> Maybe [a]

+

init :: [a] -> Maybe [a]

Takes a list and returns Just a list containing all but the last of the list's elements if the list contains at least one element; @@ -1538,7 +1538,7 @@ Just([1, 2]) Nothing() ``` -

take :: Integer -> [a] -> Maybe [a]

+

take :: Integer -> [a] -> Maybe [a]

Returns Just the first N elements of the given collection if N is greater than or equal to zero and less than or equal to the length @@ -1556,7 +1556,7 @@ Just('abcd') Nothing() ``` -

takeLast :: Integer -> [a] -> Maybe [a]

+

takeLast :: Integer -> [a] -> Maybe [a]

Returns Just the last N elements of the given collection if N is greater than or equal to zero and less than or equal to the length @@ -1574,7 +1574,7 @@ Just('defg') Nothing() ``` -

drop :: Integer -> [a] -> Maybe [a]

+

drop :: Integer -> [a] -> Maybe [a]

Returns Just all but the first N elements of the given collection if N is greater than or equal to zero and less than or equal to the @@ -1592,7 +1592,7 @@ Just('efg') Nothing() ``` -

dropLast :: Integer -> [a] -> Maybe [a]

+

dropLast :: Integer -> [a] -> Maybe [a]

Returns Just all but the last N elements of the given collection if N is greater than or equal to zero and less than or equal to the @@ -1610,7 +1610,7 @@ Just('abc') Nothing() ``` -

reverse :: [a] -> [a]

+

reverse :: [a] -> [a]

Returns the elements of the given list in reverse order. @@ -1622,7 +1622,7 @@ Returns the elements of the given list in reverse order. 'cba' ``` -

indexOf :: a -> [a] -> Maybe Integer

+

indexOf :: a -> [a] -> Maybe Integer

Takes a value of any type and a list, and returns Just the index of the first occurrence of the value in the list, if applicable; @@ -1646,7 +1646,7 @@ Just(1) Nothing() ``` -

lastIndexOf :: a -> [a] -> Maybe Integer

+

lastIndexOf :: a -> [a] -> Maybe Integer

Takes a value of any type and a list, and returns Just the index of the last occurrence of the value in the list, if applicable; @@ -1672,7 +1672,7 @@ Nothing() ### Array -

append :: a -> Array a -> Array a

+

append :: a -> Array a -> Array a

Takes a value of any type and an array of values of that type, and returns the result of appending the value to the array. @@ -1684,7 +1684,7 @@ See also [`prepend`](#prepend). [1, 2, 3] ``` -

prepend :: a -> Array a -> Array a

+

prepend :: a -> Array a -> Array a

Takes a value of any type and an array of values of that type, and returns the result of prepending the value to the array. @@ -1696,7 +1696,7 @@ See also [`append`](#append). [1, 2, 3] ``` -

find :: (a -> Boolean) -> Array a -> Maybe a

+

find :: (a -> Boolean) -> Array a -> Maybe a

Takes a predicate and an array and returns Just the leftmost element of the array which satisfies the predicate; Nothing if none of the array's @@ -1710,7 +1710,7 @@ Just(-2) Nothing() ``` -

pluck :: Accessible a => TypeRep b -> String -> Array a -> Array (Maybe b)

+

pluck :: Accessible a => TypeRep b -> String -> Array a -> Array (Maybe b)

Takes a [type representative](#type-representatives), a property name, and an array of objects and returns an array of equal length. Each @@ -1725,7 +1725,7 @@ See also [`get`](#get). [Just(1), Just(2), Nothing(), Nothing(), Nothing()] ``` -

reduce :: Foldable f => (a -> b -> a) -> a -> f b -> a

+

reduce :: Foldable f => (a -> b -> a) -> a -> f b -> a

Takes a curried binary function, an initial value, and a [Foldable][], and applies the function to the initial value and the Foldable's first @@ -1745,11 +1745,11 @@ See also [`reduce_`](#reduce_). [5, 4, 3, 2, 1] ``` -

reduce_ :: Foldable f => ((a, b) -> a) -> a -> f b -> a

+

reduce_ :: Foldable f => ((a, b) -> a) -> a -> f b -> a

Version of [`reduce`](#reduce) accepting uncurried functions. -

unfoldr :: (b -> Maybe (Pair a b)) -> b -> Array a

+

unfoldr :: (b -> Maybe (Pair a b)) -> b -> Array a

Takes a function and a seed value, and returns an array generated by applying the function repeatedly. The array is initially empty. The @@ -1766,7 +1766,7 @@ of the function should result in either: [1, 2, 3, 4] ``` -

range :: Integer -> Integer -> Array Integer

+

range :: Integer -> Integer -> Array Integer

Returns an array of consecutive integers starting with the first argument and ending with the second argument minus one. Returns `[]` if the second @@ -1785,7 +1785,7 @@ argument is less than or equal to the first argument. ### Object -

prop :: Accessible a => String -> a -> b

+

prop :: Accessible a => String -> a -> b

Takes a property name and an object with known properties and returns the value of the specified property. If for some reason the object @@ -1798,7 +1798,7 @@ For accessing properties of uncertain objects, use [`get`](#get) instead. 1 ``` -

get :: Accessible a => TypeRep b -> String -> a -> Maybe b

+

get :: Accessible a => TypeRep b -> String -> a -> Maybe b

Takes a [type representative](#type-representatives), a property name, and an object and returns Just the value of the specified object @@ -1821,7 +1821,7 @@ Nothing() Nothing() ``` -

gets :: Accessible a => TypeRep b -> Array String -> a -> Maybe b

+

gets :: Accessible a => TypeRep b -> Array String -> a -> Maybe b

Takes a [type representative](#type-representatives), an array of property names, and an object and returns Just the value at the path @@ -1841,7 +1841,7 @@ Nothing() Nothing() ``` -

keys :: StrMap a -> Array String

+

keys :: StrMap a -> Array String

Returns the keys of the given string map, in arbitrary order. @@ -1850,7 +1850,7 @@ Returns the keys of the given string map, in arbitrary order. ['a', 'b', 'c'] ``` -

values :: StrMap a -> Array a

+

values :: StrMap a -> Array a

Returns the values of the given string map, in arbitrary order. @@ -1859,7 +1859,7 @@ Returns the values of the given string map, in arbitrary order. [1, 2, 3] ``` -

toPairs :: StrMap a -> Array (Pair String a)

+

pairs :: StrMap a -> Array (Pair String a)

Returns the key–value pairs of the given string map, in arbitrary order. @@ -1870,7 +1870,7 @@ Returns the key–value pairs of the given string map, in arbitrary order. ### Number -

negate :: ValidNumber -> ValidNumber

+

negate :: ValidNumber -> ValidNumber

Negates its argument. @@ -1882,7 +1882,7 @@ Negates its argument. 42 ``` -

add :: FiniteNumber -> FiniteNumber -> FiniteNumber

+

add :: FiniteNumber -> FiniteNumber -> FiniteNumber

Returns the sum of two (finite) numbers. @@ -1891,7 +1891,7 @@ Returns the sum of two (finite) numbers. 2 ``` -

sum :: Foldable f => f FiniteNumber -> FiniteNumber

+

sum :: Foldable f => f FiniteNumber -> FiniteNumber

Returns the sum of the given array of (finite) numbers. @@ -1909,7 +1909,7 @@ Returns the sum of the given array of (finite) numbers. 0 ``` -

sub :: FiniteNumber -> FiniteNumber -> FiniteNumber

+

sub :: FiniteNumber -> FiniteNumber -> FiniteNumber

Returns the difference between two (finite) numbers. @@ -1918,7 +1918,7 @@ Returns the difference between two (finite) numbers. 2 ``` -

inc :: FiniteNumber -> FiniteNumber

+

inc :: FiniteNumber -> FiniteNumber

Increments a (finite) number by one. @@ -1927,7 +1927,7 @@ Increments a (finite) number by one. 2 ``` -

dec :: FiniteNumber -> FiniteNumber

+

dec :: FiniteNumber -> FiniteNumber

Decrements a (finite) number by one. @@ -1936,7 +1936,7 @@ Decrements a (finite) number by one. 1 ``` -

mult :: FiniteNumber -> FiniteNumber -> FiniteNumber

+

mult :: FiniteNumber -> FiniteNumber -> FiniteNumber

Returns the product of two (finite) numbers. @@ -1945,7 +1945,7 @@ Returns the product of two (finite) numbers. 8 ``` -

product :: Foldable f => f FiniteNumber -> FiniteNumber

+

product :: Foldable f => f FiniteNumber -> FiniteNumber

Returns the product of the given array of (finite) numbers. @@ -1963,7 +1963,7 @@ Returns the product of the given array of (finite) numbers. 1 ``` -

div :: FiniteNumber -> NonZeroFiniteNumber -> FiniteNumber

+

div :: FiniteNumber -> NonZeroFiniteNumber -> FiniteNumber

Returns the result of dividing its first argument (a finite number) by its second argument (a non-zero finite number). @@ -1973,7 +1973,7 @@ its second argument (a non-zero finite number). 3.5 ``` -

min :: Ord a => a -> a -> a

+

min :: Ord a => a -> a -> a

Returns the smaller of its two arguments. @@ -1994,7 +1994,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. @@ -2017,7 +2017,7 @@ new Date('2000-01-01') ### Integer -

even :: Integer -> Boolean

+

even :: Integer -> Boolean

Returns `true` if the given integer is even; `false` if it is odd. @@ -2029,7 +2029,7 @@ true false ``` -

odd :: Integer -> Boolean

+

odd :: Integer -> Boolean

Returns `true` if the given integer is odd; `false` if it is even. @@ -2043,7 +2043,7 @@ false ### Parse -

parseDate :: String -> Maybe Date

+

parseDate :: String -> Maybe Date

Takes a string and returns Just the date represented by the string if it does in fact represent a date; Nothing otherwise. @@ -2056,7 +2056,7 @@ Just(new Date('2011-01-19T17:40:00.000Z')) Nothing() ``` -

parseFloat :: String -> Maybe Number

+

parseFloat :: String -> Maybe Number

Takes a string and returns Just the number represented by the string if it does in fact represent a number; Nothing otherwise. @@ -2069,7 +2069,7 @@ Just(-123.45) Nothing() ``` -

parseInt :: Integer -> String -> Maybe Integer

+

parseInt :: Integer -> String -> Maybe Integer

Takes a radix (an integer between 2 and 36 inclusive) and a string, and returns Just the number represented by the string if it does in @@ -2091,7 +2091,7 @@ Just(255) Nothing() ``` -

parseJson :: TypeRep a -> String -> Maybe a

+

parseJson :: TypeRep a -> String -> Maybe a

Takes a [type representative](#type-representatives) and a string which may or may not be valid JSON, and returns Just the result of applying @@ -2111,7 +2111,7 @@ Nothing() ### RegExp -

regex :: RegexFlags -> String -> RegExp

+

regex :: RegexFlags -> String -> RegExp

Takes a [RegexFlags][] and a pattern, and returns a RegExp. @@ -2120,7 +2120,7 @@ Takes a [RegexFlags][] and a pattern, and returns a RegExp. /:\d+:/g ``` -

regexEscape :: String -> String

+

regexEscape :: String -> String

Takes a string which may contain regular expression metacharacters, and returns a string with those metacharacters escaped. @@ -2134,7 +2134,7 @@ Properties: '\\-=\\*\\{XYZ\\}\\*=\\-' ``` -

test :: RegExp -> String -> Boolean

+

test :: RegExp -> String -> Boolean

Takes a pattern and a string, and returns `true` if the pattern matches the string; `false` otherwise. @@ -2147,7 +2147,7 @@ true false ``` -

match :: RegExp -> String -> Maybe (Array (Maybe String))

+

match :: RegExp -> String -> Maybe (Array (Maybe String))

Takes a pattern and a string, and returns Just an array of matches if the pattern matches the string; Nothing otherwise. Each match has @@ -2164,7 +2164,7 @@ Just([Just('bye'), Nothing()]) ### String -

toUpper :: String -> String

+

toUpper :: String -> String

Returns the upper-case equivalent of its argument. @@ -2175,7 +2175,7 @@ See also [`toLower`](#toLower). 'ABC DEF 123' ``` -

toLower :: String -> String

+

toLower :: String -> String

Returns the lower-case equivalent of its argument. @@ -2186,7 +2186,7 @@ See also [`toUpper`](#toUpper). 'abc def 123' ``` -

trim :: String -> String

+

trim :: String -> String

Strips leading and trailing whitespace characters. @@ -2195,7 +2195,7 @@ Strips leading and trailing whitespace characters. 'foo bar' ``` -

words :: String -> Array String

+

words :: String -> Array String

Takes a string and returns the array of words the string contains (words are delimited by whitespace characters). @@ -2207,7 +2207,7 @@ See also [`unwords`](#unwords). ['foo', 'bar', 'baz'] ``` -

unwords :: Array String -> String

+

unwords :: Array String -> String

Takes an array of words and returns the result of joining the words with separating spaces. @@ -2219,7 +2219,7 @@ See also [`words`](#words). 'foo bar baz' ``` -

lines :: String -> Array String

+

lines :: String -> Array String

Takes a string and returns the array of lines the string contains (lines are delimited by newlines: `'\n'` or `'\r\n'` or `'\r'`). @@ -2232,7 +2232,7 @@ See also [`unlines`](#unlines). ['foo', 'bar', 'baz'] ``` -

unlines :: Array String -> String

+

unlines :: Array String -> String

Takes an array of lines and returns the result of joining the lines after appending a terminating line feed (`'\n'`) to each. diff --git a/bower.json b/bower.json index cb9dcf73..a2589289 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "sanctuary", - "version": "0.11.0", + "version": "0.11.1", "description": "Refuge from unsafe JavaScript", "license": "MIT", "repository": { diff --git a/package.json b/package.json index b1c8f68f..1edb099e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sanctuary", - "version": "0.11.0", + "version": "0.11.1", "description": "Refuge from unsafe JavaScript", "license": "MIT", "repository": {