-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
share definitions of constraints, types, and functions #514
Conversation
Sum.Type | ||
]) | ||
}); | ||
}(require('.'))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We define S
here for the benefit of the doctests.
// createSanctuary :: Options -> Module | ||
function createSanctuary(opts) { | ||
|
||
/* eslint-disable indent */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.js
Outdated
createSanctuary); | ||
function create(opts) { | ||
var S = { | ||
env: defaultEnv, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be opts.env
rather than defaultEnv
, should it not? If others agree, I'll open a separate pull request for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S[name] = def(name, _[name].consts, _[name].types, _[name].impl); | ||
}); | ||
return S; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is several thousand lines smaller than createSanctuary
. ;)
8cd7de9
to
e4e60dd
Compare
To make certain I understand, you pulled the definitions out of |
Before: function createSanctuary(opts) {
var S = {};
// Sanctuary functions (including ‘create’) defined here.
return S;
}
return createSanctuary({checkTypes: true, env: defaultEnv});
After: // Sanctuary functions (including ‘create’) defined at the top level.
return create({checkTypes: true, env: defaultEnv});
|
LGTM |
//. . ({x, y, width, height}) | ||
//. . ) | ||
//. createRect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
3d435a4
to
565195f
Compare
Currently, each Sanctuary function is defined once for each Sanctuary module created. This pull request restructures the code so that constraints, types, and functions are defined just once.