Skip to content

Commit

Permalink
Merge pull request #6 from phadej/0.2.0
Browse files Browse the repository at this point in the history
0.2.0
  • Loading branch information
phadej committed Aug 5, 2013
2 parents e9616ef + fed839a commit 3e35abf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ var foo = typify("foo :: number -> number.. -> number", function (a) {

## Documentation

### API

- `typify(functionSpec, fun)` - decorate function with run-time type check
- `typify.create()` - create new typify environment
- `typify.type(typename, checkFun)` - add new type with user-supplied existence check
- `typify.record(typename, recordspec)` - add new record type
- `typify.alias(typename, typespec)` - give name to the compound type
- `typify.check(typename, value) -> bool` - check membership of value in the type

### Checkable type

*Checkable* means, that given an object you can check whether an object is or isn't of the particular type.
Expand Down Expand Up @@ -102,6 +111,15 @@ console.log(add(1, 2)); // ok
console.log(add("foo", "bar")); // throws TypeError
```

#### Formal syntax of function type declaration:

- *function type* λ ::= ν μ | ν Γ (σ `->`)* ρ σ
- *action* μ ::= `->` τ
- *context* Γ ::= α `:` Σ (`,` α `:` Σ)* `=>` | ε
- *typeset* Σ ::= σ_poly (`|` σ_poly)*
- *rest parameters* ρ ::= σ `...` `->` | `...` `->` | ε
- *function name* ν ::= *identifier* `::` | ε

### New types

New types can be added with `typify.type` method:
Expand Down Expand Up @@ -136,7 +154,6 @@ typ.record("bst", {
});
```


### Hygiene usage

If you don't want to use global type database, you can create your own instance of *typify*:
Expand All @@ -154,22 +171,19 @@ var myTypify = typify.create();
var typify = require("typify").create();
```

#### Formal syntax of function type declaration:

- *function type* λ ::= ν μ | ν Γ (σ `->`)* ρ σ
- *action* μ ::= `->` τ
- *context* Γ ::= α `:` Σ (`,` α `:` Σ)* `=>` | ε
- *typeset* Σ ::= σ_poly (`|` σ_poly)*
- *rest parameters* ρ ::= σ `...` `->` | `...` `->` | ε
- *function name* ν ::= *identifier* `::` | ε

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

- You can use `grunt jasmine-build` to generate `_SpecRunner.html` to run tests in your browser of choice.

## Release History

- 0.2.0
- Recursive record types
- Recursive aliases
- Intersection types
- Hygiene type environments

- 0.1.1
- Record type
- Fixed typos in README.md
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typify",
"description": "Runtime type-checking for JavaScript.",
"version": "0.1.1",
"version": "0.2.0",
"homepage": "https://github.com/phadej/typify",
"author": "Oleg Grenrus <[email protected]>",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typify",
"description": "Runtime type-checking for JavaScript.",
"version": "0.1.1",
"version": "0.2.0",
"homepage": "https://github.com/phadej/typify",
"author": {
"name": "Oleg Grenrus",
Expand Down

0 comments on commit 3e35abf

Please sign in to comment.