Skip to content

Commit

Permalink
rephrase references to "methods"
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed Oct 22, 2016
1 parent c8e83c4 commit 7d386d2
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,17 @@ have dependencies on other algebras which must be implemented.
- Two promises are equivalent when they yield equivalent values.
- Two functions are equivalent if they yield equivalent outputs for equivalent inputs.

## Prefixed method names
## Prefixed property names

In order to add compatibility with Fantasy Land to your library,
you need to add methods that you want to support with `fantasy-land/` prefix.
For example if a type implements Functors' [`map`][], you need to add `fantasy-land/map` method to it.
The code may look something like this:
In order for a data type to be compatible with Fantasy Land, its values must
have certain properties. These properties are all prefixed by `fantasy-land/`.
For example:

```js
MyType.prototype['fantasy-land/map'] = MyType.prototype.map
// MyType#fantasy-land/map :: MyType a ~> (a -> b) -> MyType b
MyType.prototype['fantasy-land/map'] = ...
```

It's not required to add unprefixed methods (e.g. `MyType.prototype.map`)
for compatibility with Fantasy Land, but you're free to do so of course.

Further in this document unprefixed names are used just to reduce noise.

For convenience you can use `fantasy-land` package:
Expand All @@ -69,7 +66,7 @@ var fl = require('fantasy-land')

// ...

MyType.prototype[fl.map] = MyType.prototype.map
MyType.prototype[fl.map] = ...

// ...

Expand Down Expand Up @@ -514,7 +511,7 @@ The `profunctor` method takes two arguments:
## Derivations

When creating data types which satisfy multiple algebras, authors may choose
to implement certain methods then derive the remaining methods. Derivations:
to implement some then derive others. Derivations:

- [`map`][] may be derived from [`ap`][] and [`of`][]:

Expand Down Expand Up @@ -591,13 +588,13 @@ be equivalent to that of the derivation (or derivations).

## Notes

1. If there's more than a single way to implement the methods and
laws, the implementation should choose one and provide wrappers for
other uses.
1. If there's more than one way to implement a method and satisfy the
associated laws, the implementation should choose one behaviour and
provide wrappers for other uses.
2. It's discouraged to overload the specified methods. It can easily
result in broken and buggy behaviour.
3. It is recommended to throw an exception on unspecified behaviour.
4. An `Id` container which implements all methods is provided in
4. An `Id` container which satisfies many of the algebras is provided in
`id.js`.


Expand Down

0 comments on commit 7d386d2

Please sign in to comment.