diff --git a/README.md b/README.md index 4998234..aeb5ee3 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ add('X'); // The value at position 1 is not a member of ‘Number’. ``` -

__ :: Placeholder

+

__ :: Placeholder

The special placeholder value. @@ -182,41 +182,41 @@ Conceptually, a type is a set of values. One can think of a value of type `Type` as a function of type `Any -> Boolean` which tests values for membership in the set (though this is an oversimplification). -

Any :: Type

+

Any :: Type

Type comprising every JavaScript value. -

AnyFunction :: Type

+

AnyFunction :: Type

Type comprising every Function value. -

Arguments :: Type

+

Arguments :: Type

Type comprising every [`arguments`][arguments] object. -

Array :: Type -⁠> Type

+

Array :: Type -⁠> Type

Constructor for homogeneous Array types. -

Boolean :: Type

+

Boolean :: Type

Type comprising `true` and `false`. -

Date :: Type

+

Date :: Type

Type comprising every Date value. -

Error :: Type

+

Error :: Type

Type comprising every Error value, including values of more specific constructors such as [`SyntaxError`][] and [`TypeError`][]. -

FiniteNumber :: Type

+

FiniteNumber :: Type

Type comprising every [`ValidNumber`][] value except `Infinity` and `-Infinity`. -

Function :: Array Type -⁠> Type

+

Function :: Array Type -⁠> Type

Constructor for Function types. @@ -226,72 +226,72 @@ Examples: type; and - `$.Function([a, b, a])` represents the `(a, b) -> a` type. -

GlobalRegExp :: Type

+

GlobalRegExp :: Type

Type comprising every [`RegExp`][] value whose `global` flag is `true`. See also [`NonGlobalRegExp`][]. -

Integer :: Type

+

Integer :: Type

Type comprising every integer in the range [[`Number.MIN_SAFE_INTEGER`][min] .. [`Number.MAX_SAFE_INTEGER`][max]]. -

NegativeFiniteNumber :: Type

+

NegativeFiniteNumber :: Type

Type comprising every [`FiniteNumber`][] value less than zero. -

NegativeInteger :: Type

+

NegativeInteger :: Type

Type comprising every [`Integer`][] value less than zero. -

NegativeNumber :: Type

+

NegativeNumber :: Type

Type comprising every [`Number`][] value less than zero. -

NonEmpty :: Type -⁠> Type

+

NonEmpty :: Type -⁠> Type

Constructor for non-empty types. `$.NonEmpty($.String)`, for example, is the type comprising every [`String`][] value except `''`. The given type must satisfy the [Monoid][] and [Setoid][] specifications. -

NonGlobalRegExp :: Type

+

NonGlobalRegExp :: Type

Type comprising every [`RegExp`][] value whose `global` flag is `false`. See also [`GlobalRegExp`][]. -

NonNegativeInteger :: Type

+

NonNegativeInteger :: Type

Type comprising every non-negative [`Integer`][] value (including `-0`). Also known as the set of natural numbers under ISO 80000-2:2009. -

NonZeroFiniteNumber :: Type

+

NonZeroFiniteNumber :: Type

Type comprising every [`FiniteNumber`][] value except `0` and `-0`. -

NonZeroInteger :: Type

+

NonZeroInteger :: Type

Type comprising every [`Integer`][] value except `0` and `-0`. -

NonZeroValidNumber :: Type

+

NonZeroValidNumber :: Type

Type comprising every [`ValidNumber`][] value except `0` and `-0`. -

Null :: Type

+

Null :: Type

Type whose sole member is `null`. -

Nullable :: Type -⁠> Type

+

Nullable :: Type -⁠> Type

Constructor for types which include `null` as a member. -

Number :: Type

+

Number :: Type

Type comprising every primitive Number value (including `NaN`). -

Object :: Type

+

Object :: Type

Type comprising every "plain" Object value. Specifically, values created via: @@ -301,28 +301,28 @@ created via: - the `new` operator in conjunction with `Object` or a custom constructor function. -

Pair :: Type -⁠> Type -⁠> Type

+

Pair :: Type -⁠> Type -⁠> Type

Constructor for tuple types of length 2. Arrays are said to represent tuples. `['foo', 42]` is a member of `Pair String Number`. -

PositiveFiniteNumber :: Type

+

PositiveFiniteNumber :: Type

Type comprising every [`FiniteNumber`][] value greater than zero. -

PositiveInteger :: Type

+

PositiveInteger :: Type

Type comprising every [`Integer`][] value greater than zero. -

PositiveNumber :: Type

+

PositiveNumber :: Type

Type comprising every [`Number`][] value greater than zero. -

RegExp :: Type

+

RegExp :: Type

Type comprising every RegExp value. -

RegexFlags :: Type

+

RegexFlags :: Type

Type comprising the canonical RegExp flags: @@ -335,34 +335,34 @@ Type comprising the canonical RegExp flags: - `'im'` - `'gim'` -

StrMap :: Type -⁠> Type

+

StrMap :: Type -⁠> Type

Constructor for homogeneous Object types. `{foo: 1, bar: 2, baz: 3}`, for example, is a member of `StrMap Number`; `{foo: 1, bar: 2, baz: 'XXX'}` is not. -

String :: Type

+

String :: Type

Type comprising every primitive String value. -

Symbol :: Type

+

Symbol :: Type

Type comprising every Symbol value. -

Type :: Type

+

Type :: Type

Type comprising every `Type` value. -

TypeClass :: Type

+

TypeClass :: Type

Type comprising every [`TypeClass`][] value. -

Undefined :: Type

+

Undefined :: Type

Type whose sole member is `undefined`. -

Unknown :: Type

+

Unknown :: Type

Type used to represent missing type information. The type of `[]`, for example, is `Array ???`. @@ -379,34 +379,34 @@ to include an infinite number of types in an environment: - `List (List (List String))` - `...` -

ValidDate :: Type

+

ValidDate :: Type

Type comprising every [`Date`][] value except `new Date(NaN)`. -

ValidNumber :: Type

+

ValidNumber :: Type

Type comprising every [`Number`][] value except `NaN`. -

env :: Array Type

+

env :: Array Type

An array of [types][]: - - AnyFunction - - Arguments - - Array(Unknown) - - Boolean - - Date - - Error - - Null - - Number - - Object - - RegExp - - StrMap(Unknown) - - String - - Symbol - - Undefined - -

test :: Array Type -⁠> Type -⁠> a -⁠> Boolean

+ - [AnyFunction](#AnyFunction) + - [Arguments](#Arguments) + - [Array](#Array)([Unknown](#Unknown)) + - [Boolean](#Boolean) + - [Date](#Date) + - [Error](#Error) + - [Null](#Null) + - [Number](#Number) + - [Object](#Object) + - [RegExp](#RegExp) + - [StrMap](#StrMap)([Unknown](#Unknown)) + - [String](#String) + - [Symbol](#Symbol) + - [Undefined](#Undefined) + +

test :: Array Type -⁠> Type -⁠> a -⁠> Boolean

Takes an environment, a type, and any value. Returns `true` if the value is a member of the type; `false` otherwise. @@ -433,7 +433,7 @@ and validate the bodies of incoming POST requests against these types. sanctuary-def provides several functions for defining types. -

NullaryType :: String -⁠> String -⁠> (Any -⁠> Boolean) -⁠> Type

+

NullaryType :: String -⁠> String -⁠> (Any -⁠> Boolean) -⁠> Type

Type constructor for types with no type variables (such as [`Number`][]). @@ -496,7 +496,7 @@ rem(42, 0); // The value at position 1 is not a member of ‘NonZeroInteger’. ``` -

UnaryType :: String -⁠> String -⁠> (Any -⁠> Boolean) -⁠> (t a -⁠> Array a) -⁠> (Type -⁠> Type)

+

UnaryType :: String -⁠> String -⁠> (Any -⁠> Boolean) -⁠> (t a -⁠> Array a) -⁠> (Type -⁠> Type)

Type constructor for types with one type variable (such as [`Array`][]). @@ -575,7 +575,7 @@ fromMaybe(0, Just('XXX')); // Since there is no type of which all the above values are members, the type-variable constraint has been violated. ``` -

BinaryType :: String -⁠> String -⁠> (Any -⁠> Boolean) -⁠> (t a b -⁠> Array a) -⁠> (t a b -⁠> Array b) -⁠> (Type -⁠> Type -⁠> Type)

+

BinaryType :: String -⁠> String -⁠> (Any -⁠> Boolean) -⁠> (t a b -⁠> Array a) -⁠> (t a b -⁠> Array b) -⁠> (Type -⁠> Type -⁠> Type)

Type constructor for types with two type variables (such as [`Pair`][]). @@ -666,7 +666,7 @@ showCard(Pair('X', '♠')); // The value at position 1 is not a member of ‘Rank’. ``` -

EnumType :: String -⁠> String -⁠> Array Any -⁠> Type

+

EnumType :: String -⁠> String -⁠> Array Any -⁠> Type

Type constructor for [enumerated types][] (such as [`RegexFlags`][]). @@ -689,7 +689,7 @@ const Denomination = $.EnumType( ); ``` -

RecordType :: StrMap Type -⁠> Type

+

RecordType :: StrMap Type -⁠> Type

`RecordType` is used to construct record types. The type definition specifies the name and type of each required field. @@ -739,7 +739,7 @@ dist(0); // The value at position 1 is not a member of ‘{ x :: FiniteNumber, y :: FiniteNumber }’. ``` -

TypeVariable :: String -⁠> Type

+

TypeVariable :: String -⁠> Type

Polymorphism is powerful. Not being able to define a function for all types would be very limiting indeed: one couldn't even define the @@ -793,7 +793,7 @@ cmp(0, '1'); // Since there is no type of which all the above values are members, the type-variable constraint has been violated. ``` -

UnaryTypeVariable :: String -⁠> (Type -⁠> Type)

+

UnaryTypeVariable :: String -⁠> (Type -⁠> Type)

Combines [`UnaryType`][] and [`TypeVariable`][]. @@ -840,7 +840,7 @@ example, is `v`. One could replace `Functor => f` with `Map k` or with This shallow inspection makes it possible to constrain a value's "outer" and "inner" types independently. -

BinaryTypeVariable :: String -⁠> (Type -⁠> Type -⁠> Type)

+

BinaryTypeVariable :: String -⁠> (Type -⁠> Type -⁠> Type)

Combines [`BinaryType`][] and [`TypeVariable`][]. @@ -855,12 +855,12 @@ To define a binary type variable `t a b` one must provide: The more detailed explanation of [`UnaryTypeVariable`][] also applies to `BinaryTypeVariable`. -

Thunk :: Type -⁠> Type

+

Thunk :: Type -⁠> Type

`$.Thunk(T)` is shorthand for `$.Function([T])`, the type comprising every nullary function (thunk) which returns a value of type `T`. -

Predicate :: Type -⁠> Type

+

Predicate :: Type -⁠> Type

`$.Predicate(T)` is shorthand for `$.Function([T, $.Boolean])`, the type comprising every predicate function which takes a value of type `T`. diff --git a/index.js b/index.js index 1625925..45deda0 100644 --- a/index.js +++ b/index.js @@ -419,7 +419,7 @@ // functionUrl :: String -> String function functionUrl(name) { - var version = '0.13.1'; // updated programmatically + var version = '0.14.0'; // updated programmatically return 'https://github.com/sanctuary-js/sanctuary-def/tree/v' + version + '#' + stripNamespace(name); } diff --git a/package.json b/package.json index 7be6fc9..e9ff1ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sanctuary-def", - "version": "0.13.1", + "version": "0.14.0", "description": "Run-time type system for JavaScript", "license": "MIT", "repository": { diff --git a/test/index.js b/test/index.js index befb7c8..68fe165 100644 --- a/test/index.js +++ b/test/index.js @@ -37,7 +37,7 @@ function throws(f, type, message) { } // version :: String -var version = '0.13.1'; // updated programmatically +var version = '0.14.0'; // updated programmatically var def = $.create({checkTypes: true, env: $.env});