-
-
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
Module scoping #479
Comments
Perhaps we don't need a dedicated function for this: IIFEs work well. In this example we disable type checking for a block of code: (S => S.add ('abc') (123)) (S.create ({checkTypes: false, env: []}));
// => 'abc123' In this example we use a stricter environment which does not permit the use of (S => {
S.I (Infinity);
// => Infinity
S.I (NaN);
// ! TypeError: Unrecognized value
//
// I :: a -> a
// ^
// 1
//
// 1) NaN :: (no types)
//
// The value at position 1 is not a member of any type in the environment.
//
// The environment contains the following types:
//
// - ValidNumber
}) (S.create ({checkTypes: true, env: [$.ValidNumber]})); Similarly, we could provide an environment which contains some of our own types. |
@davidchambers And what about a new param Or with |
Something like this, do you mean? S.create ({inherit: true, env: [$.ValidNumber]}) In the example above We could do this instead: S.create ({checkTypes: S.Nothing, env: S.Just ([$.ValidNumber])}) Simpler, though, would be to expose S.create ({checkTypes: S.checkTypes, env: [$.ValidNumber]}) |
I need to think about how to approach the underlying problem (adding new types in a seamless way into a given scope). At the end of the day, there should be an approach to avoid having to declare types in a header section that represents giving them to What disturbs me is not being able to declare new types where I need them: now I need to declare them in a separate file / scope. That is, actual code requiring these types isn't expressive: how do I know the whole type when I read my code? |
Probably this could be an approach:
|
Can this issue be closed now that we have |
Hi!
As @davidchambers and I have been discussing, there's an interesting feature that would allow us to create Sanctuary module scopes.
What's the purpose of this?
Pseudo-code:
That is, child Sanctuary scope would inherit parent's
env
while it would be able to overridecheckTypes
.I find this convenient in order to let us define new types as you need them instead of having to load them during program startup.
The text was updated successfully, but these errors were encountered: