sanctuary-js / sanctuary

:see_no_evil: Refuge from unsafe JavaScript
https://sanctuary.js.org
MIT License
3.03k stars 94 forks source link

update S.env to reference the module's environment #524

Closed davidchambers closed 6 years ago

davidchambers commented 6 years ago

S.env is currently a reference to the default environment for every Sanctuary module S. It would be more useful for S.env to reference the particular environment provided when creating S, enabling:

const S0 = require ('sanctuary');
const S1 = S0.create ({checkTypes: ..., env: S0.env.concat ([...])});
const S2 = S1.create ({checkTypes: ..., env: S1.env.concat ([...])});

One would currently need to keep track of the various environments in some other way:

const S0 = require ('sanctuary');
const env1 = S0.env.concat ([...]);
const S1 = S0.create ({checkTypes: ..., env: env1});
const env2 = env1.concat ([...]);
const S2 = S1.create ({checkTypes: ..., env: env2});
Avaq commented 6 years ago

I believe this makes progress towards (or is completely?) solving #479

Avaq commented 6 years ago

It might also be related to https://github.com/sanctuary-js/sanctuary-def/issues/137