gluon
gluon copied to clipboard
Add glob imports
// Imports `List, monad, ...`
let { monad = { .. } } = import! "std/io.glu"
// or perhaps
let { { * } } = import! "std/list.glu"
This would import all fields (both type and value fields) into scope of the given record.
One potential problem is polymorphic records
let test record =
// At this point all we can say is that `record` must be a record but we don't know which fields it has
// so we can't bring any bindings into scope
let { .. } = record
// Apparently `x` was a field of `record` but this will still error
x + record.x
May need to make it a hard error to use a glob on a polymorphic record
Turns out I did have an issue for this #2 😆 . This issue is more comprehensive though so closing it in favor for this.
Yes please :)
Maybe let * = import! "std/list.glu" or let _ = import! "std/list.glu".
I would prefer a syntax that doesn't require doubly nested braces :)
It would be very useful for artistic live scripting to have glob imports. (In that scenario, speed of typing (expressing ideas) matters most, and the code can be cleaned up later.)