Host-independent project and workspace transformation engine
Host files → frontend → current Morphir IR → Scheme transforms → backend → artifactsmise exec -- moon run pkgs/morphir-engine/examples --target native
# Also supported: --target js, --target wasm, --target wasm-gc| morphir.json | Configuration |
|---|---|
| name (default user; must be a valid package name) | project.name |
| sourceDirectory (default src) | project.source_directory |
| exposedModules (required list of module names) | project.exposed_modules |
| none | frontend.language = "elm" |
| none | default pipeline.backend = "checkpoint", pipeline.checkpoint_format = "morphir-json" (system, global and workspace configuration can replace them) |
let host = @engine.Host::memory(Map::from_array([
("demo/morphir.toml", "[project]\nname = 'demo'\nsource_directory = 'src'\n"),
("demo/src/main.scm", "(* 6 7)"),
]))
let engine = @engine.Engine::new()
let report = engine.run(host, @engine.Project("demo"))
// report.artifacts[0].path == "demo/dist/main.ir.json"| Input | Discovery |
|---|---|
| File(path) | One file, regardless of extension; parent directory supplies config |
| Directory(root) | Recursively listed files matching the selected frontend extensions |
| Project(root) | morphir.toml supplies [project] name and source_directory (defaults: user, src) |
| Workspace(root) | morphir.toml lists project directories in [workspace] members, as literal paths (no *, ?, [ or {) |
[workspace]
members = ['packages/orders', 'packages/pricing'](pipeline
(frontend "scheme")
(backend "ir-json")
(output "generated")
(transform
(lambda (file)
(ir-rewrite-file file
(lambda (node)
(if (ir-integer? node)
(ir-with-integer node (+ (ir-integer node) 2))
node))))))| Value | Effect |
|---|---|
| off (default) | No inference. The IR is unchanged. |
| fill | Writes the solved types into the IR: an inferred_type on each node, and the solutions of the signature types that have the unknown marker. |
| check | Checks the IR and does not change it. |
[metadata]
provider = "shared-local-restore"
service = "tools/morphir-provider-host"
policy = "trust/policy.json"
lock = "morphir.lock"
registry = "registry"
state = "trust/state"
assurance = "portable"
[metadata.naming]
release = "example.com/morphir/naming@1.0.0"pub(all) suberror SourceFrontendError {
Rejected(String, String, SourceLocation?)
RejectedSources(Array[SourceProblem])
}pub(all) struct Artifact {
path : String
source : String
content : String
}pub(all) struct BoundarySelection {
source : String
unit_id : String
input_format : String
output_format : String
profile : String?
read_bytes : Bool
write_bytes : Bool
}pub(all) struct ComponentBoundary {
name : String
transport : String
metadata_policy : String
}pub(all) struct ContentReport {
artifacts : Array[ContentArtifact]
projects : Array[LibraryProject]
diagnostics : Array[Diagnostic]
warnings : Array[Diagnostic]
processed : Int
}pub(all) struct DataFormat {
codec : String
extensions : Array[String]
suffix : String
binary : Bool
}pub struct Engine {
// private fields
}fn Engine::execute_content(_self : Engine, plan : Plan, read : (String, Bool) -> Content raise, cancelled? : () -> Bool, on_unit? : (CompiledUnit) -> Unit) -> ContentReportfn Engine::register_generation_backend(self : Engine, name : String, backend : GenerationBackend) -> Unit raisefn Engine::register_metadata_policy(self : Engine, name : String, policy : MetadataPolicy) -> Unit raisefn Engine::register_project_metadata_provider(self : Engine, bind : (ProjectMetadataScope) -> Capabilities raise) -> Unit raisepub(all) struct GeneratedProject {
id : String
root : String
members : Array[String]
dependencies : Array[ProjectDependency]
build_contract : String
}pub(all) struct GenerationBackend {
generate : (IRUnit, Json, () -> Bool) -> GenerationBatch raise
write_bytes : Bool
validate_options : (Json) -> Unit raise
targets : Array[String]
}pub(all) struct GenerationBatch {
warnings : Array[String]
structured_warnings : Array[Warning]
files : Array[GeneratedFile]
projects : Array[GeneratedProject]
}pub(all) struct Host {
read : (String) -> String raise
exists : (String) -> Bool raise
list : (String) -> Array[String] raise
}pub(all) struct LanguageOffer {
language : LanguageId
provider : ProviderId
extensions : Array[FileExtension]
default_profile : ProfileId?
profiles : Array[ProfileOffer]
}pub(all) struct LibraryProject {
id : String
source : String
root : String
members : Array[String]
dependencies : Array[ProjectDependency]
build_contract : String
policy : BuildPolicy
}pub struct Plan {
output_root : String
// private fields
}pub(all) struct ProfileOffer {
id : ProfileId
compile : CompileKind
capabilities : SourceCapabilities?
evidence : SourceEvidence
unit_limits : Limits?
}pub(all) struct ProjectDependency {
module_name : String
version : String
api_profile : String
semantic_pin : String
}pub(all) struct ProjectInfo {
name : String
relative_path : String
frontend : String?
target : String?
error : String?
}pub(all) struct ProjectMetadataScope {
workspace_root : String
project_root : String
project_name : String
request : MetadataProviderRequest
} derive(Eq, Debug)pub(all) struct ProjectSources {
package_name : SourcePackageName
exposed_modules : Array[SourceModuleName]
sources : Array[Source]
}pub(all) struct Report {
artifacts : Array[Artifact]
diagnostics : Array[Diagnostic]
processed : Int
}pub(all) struct Request {
selector : String
all : Bool
invocation : String
file : String?
directory : String?
script : String
overlay : Document
}pub(all) struct Source {
path : String
relative_path : String
content : String
package_name : String
module_name : String
}pub(all) enum SourceCompile {
PerFile((Source, String, () -> Bool) -> IRUnit raise)
PerProject((ProjectSources, String, () -> Bool) -> IRUnit raise)
}pub(all) enum SourceEvidence {
Declared
LocalAcceptance
}pub(all) struct SourceFrontendSelection {
source : String
unit_id : String
frontend : String
language : String
provider : String
profile : String?
default_profile : Bool
available_profiles : Array[String]
capabilities : SourceCapabilities?
evidence : SourceEvidence
dependencies : Map[String, String]
output_contract : String
}pub(all) struct SourceLanguage {
id : LanguageId
extensions : Array[FileExtension]
default_profile : ProfileId
profiles : Array[SourceProfile]
}pub(all) struct SourceProblem {
code : String
detail : String
path : String
location : SourceLocation?
} derive(Debug)pub(all) struct SourceProfile {
id : ProfileId
capabilities : SourceCapabilities
evidence : SourceEvidence
dependencies : Map[String, String]
compile : SourceCompile
unit_limits : Limits
}