Skip to content

Commit

Permalink
use a thunk instead of a direct reference to the canonical module
Browse files Browse the repository at this point in the history
  • Loading branch information
rpominov committed Feb 20, 2018
1 parent 2635810 commit 85082b8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ All methods' implementations should only use type information about arguments th

## Canonical Module

A value may have a reference to a canonical module that works with values of that value's type. The reference should be in the `fantasy-land/canonical` property. For example:
A value may have a reference to a canonical module that works with values of that value's type. Such value should have a method named `fantasy-land/canonical` that returns the module. For example:

```js
const ListModule = {
of(x) {
return {'fantasy-land/canonical': ListModule, data: [x]}
return {'fantasy-land/canonical': () => ListModule, data: [x]}
},
map(f, v) {
return {'fantasy-land/canonical': ListModule, data: v.data.map(f)}
return {'fantasy-land/canonical': () => ListModule, data: v.data.map(f)}
}
}
```
Expand All @@ -115,11 +115,13 @@ const ListModule2 = {
}
}

const list = {'fantasy-land/canonical': ListModule2, data: [1]}
const list = {'fantasy-land/canonical': () => ListModule2, data: [1]}
```

Note that the `ListModule2` here is correct. Only the `list` value doesn't follow the specification.

The `fantasy-land/canonical` method must always return equivalent modules when called more than one times.


## Algebra

Expand Down

0 comments on commit 85082b8

Please sign in to comment.