From 7e449a05f115c4b2c7c0e135fab7360786c6511c Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Tue, 20 Feb 2018 19:26:55 +0300 Subject: [PATCH] use a thunk instead of a direct reference to the canonical module --- specification.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/specification.md b/specification.md index bf96f57..8d76b95 100644 --- a/specification.md +++ b/specification.md @@ -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 a 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)} } } ``` @@ -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 multiple times. + ## Algebra