Skip to content

Commit

Permalink
documentation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed May 31, 2016
1 parent 225d8f4 commit 0ca375a
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@
//.
//. Sanctuary uses Haskell-like type signatures to describe the types of
//. values, including functions. `'foo'`, for example, has type `String`;
//. `[1, 2, 3]` has type `[Number]`. The arrow (`->`) is used to express a
//. function's type. `Math.abs`, for example, has type `Number -> Number`.
//. `[1, 2, 3]` has type `Array Number`. The arrow (`->`) is used to express
//. a function's type. `Math.abs`, for example, has type `Number -> Number`.
//. That is, it takes an argument of type `Number` and returns a value of
//. type `Number`.
//.
//. [`R.map`][R.map] has type `(a -> b) -> [a] -> [b]`. That is, it takes
//. an argument of type `a -> b` and returns a value of type `[a] -> [b]`.
//. `a` and `b` are type variables: applying `R.map` to a value of type
//. `String -> Number` will give a value of type `[String] -> [Number]`.
//. [`R.map`][R.map] has type `(a -> b) -> Array a -> Array b`. That is,
//. it takes an argument of type `a -> b` and returns a value of type
//. `Array a -> Array b`. `a` and `b` are type variables: applying `R.map`
//. to a value of type `String -> Number` will result in a value of type
//. `Array String -> Array Number`.
//.
//. Sanctuary embraces types. JavaScript doesn't support algebraic data types,
//. but these can be simulated by providing a group of constructor functions
//. whose prototypes provide the same set of methods. A value of the Maybe
//. type, for example, is created via the Nothing constructor or the Just
//. constructor.
//. but these can be simulated by providing a group of data constructors which
//. return values with the same set of methods. A value of the Maybe type, for
//. example, is created via the Nothing constructor or the Just constructor.
//.
//. It's necessary to extend Haskell's notation to describe implicit arguments
//. to the *methods* provided by Sanctuary's types. In `x.map(y)`, for example,
Expand Down Expand Up @@ -135,10 +135,10 @@
//. perform type checking:
//.
//. ```javascript
//. const sanctuary = require('sanctuary');
//. const {create, env} = require('sanctuary');
//.
//. const checkTypes = process.env.NODE_ENV !== 'production';
//. const S = sanctuary.create({checkTypes: checkTypes, env: sanctuary.env});
//. const S = create({checkTypes: checkTypes, env: env});
//. ```
//.
//. ## API
Expand Down Expand Up @@ -1171,8 +1171,7 @@

//# Nothing :: -> Maybe a
//.
//. Returns a Nothing. Though this is a constructor function the `new`
//. keyword needn't be used.
//. Returns a Nothing.
//.
//. ```javascript
//. > S.Nothing()
Expand All @@ -1188,8 +1187,6 @@
//# Just :: a -> Maybe a
//.
//. Takes a value of any type and returns a Just with the given value.
//. Though this is a constructor function the `new` keyword needn't be
//. used.
//.
//. ```javascript
//. > S.Just(42)
Expand Down Expand Up @@ -1816,8 +1813,6 @@
//# Left :: a -> Either a b
//.
//. Takes a value of any type and returns a Left with the given value.
//. Though this is a constructor function the `new` keyword needn't be
//. used.
//.
//. ```javascript
//. > S.Left('Cannot divide by zero')
Expand All @@ -1834,8 +1829,6 @@
//# Right :: b -> Either a b
//.
//. Takes a value of any type and returns a Right with the given value.
//. Though this is a constructor function the `new` keyword needn't be
//. used.
//.
//. ```javascript
//. > S.Right(42)
Expand Down

0 comments on commit 0ca375a

Please sign in to comment.