feat: support `import` values from `file:` URI scheme
I am suggesting importing amorphous files using the file: URI scheme:
import (blobby : Blob) = "file:Bla.wasm";
import (texty : Text) = "file:Bla.md";
import (principally : Principal) = "file:Bla.txt";
Leaving the type away would default to Blob.
To develop this idea further, import (friends : [{ name : Text; birthday : Text; ...}]) = "file:friends.csv" would be in reach. But I am sceptical of the utility (for other than test data generation).
Eventually resolves #4934.
This is super early, I am butchering basically everything, such as
- type checker (
T.Preat bad phases) - compilation units (there should be a
ValueU) - it should be
file:// - use
check_text
I think it might be easier to have differnt uris
impor bloby = "blob:Bla.wasm"; import texty = "text:Bla.md"; import principally = "principal:Bla.txt"; import envvar= "env:USER"; import foreignclass= "class:foo.wasm";
hey @ggreif i see you made good progress here, any ETA 👀
I picked it up again, and swapping back in my brain how all the parts are interacting. It is a bit tricky how to type check it when the type is ultimately guided by the pattern, but I have an idea how to make it smooth (also for the users) and expandable in the future.
but I have an idea how to make it smooth (also for the users) and expandable in the future.
awesome, looking forward to it 🦾
Comparing from f781c1f50b6f7653cbc6c12ca98ed54627278e68 to f412c5a43fc2cc08c8e526cacfbaa21bf1b84247: The produced WebAssembly code seems to be completely unchanged. In terms of gas, no changes are observed in 5 tests. In terms of size, no changes are observed in 5 tests.
I'd prefer to have the content type be part of the import URI, similar to what Claudio proposed. That wouldn't require special casing in the type checker and allow tools that use the --print-deps flag to check the imported files according to the specified encoding, without having to perform type checking.
I think the file protocol is painting us into a corner since it's not longer obvious what the type is and we might later want to import Text values.
Why don't we just use a mo.* prefix to scope the mo specific protocols:
impor bloby = "mo.blob:/Bla.wasm"; import texty = "mo.text:/Bla.md"; (* validate as utf8 *)
Later:
import csv = "mo.csv:/foo.csv"; (* import structured constant or what ever *) import principally = "mo.principal:/Bla.txt"; import envvar= "mo.env:/USER"; import foreignclass= "mo.class:/foo.wasm"; (uses .did type to import foreign actor class *)
cf: https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
Or maybe file.* instead of mo.*
I did a doc/make preview and noticed some missing doc in the manual (we have two sections on imports). I added the doc. Will approve now.
wow very excited to use this! great work 🎉