This specification defines the contract for MagnusOpera.FScript.TypeProvider.
- Compile-time parse and type-check
.fssscripts. - Expose
[<export>]functions as strongly-typed static methods in F#. - Allow runtime script replacement with strict signature compatibility checks.
- Namespace:
FScript.TypeProvider - Type provider:
FScriptScriptProvider
Static parameters:
ScriptPath: string(required)RootDirectory: string(optional, defaults to script directory)ExternProviders: string(optional, semicolon-separated assembly-qualified provider type names)
- Resolve script path and root directory.
- Resolve externs using runtime defaults plus configured extern-provider types.
- Parse with includes from file and run type inference.
- Collect exported functions.
- Fail compilation on:
- parse/type errors,
- unsupported exported signature shapes.
For each exported function, generate one static method with mapped .NET/F# types.
Provider-generated static members:
SetRuntimeResolver : (unit -> RuntimeScriptOverride option) -> unitClearRuntimeResolver : unit -> unit
RuntimeScriptOverride fields:
RootDirectory: stringEntryFile: stringEntrySource: stringResolveImportedSource: (string -> string option) option
Supported:
unitint->int64floatboolstringlist<T>option<T>- tuples (arity
2..8) map<string, T>->Map<string, T>
Rejected:
- records
- unions
- named/custom types
- function values in argument/return positions
- unresolved type variables
- non-string map keys
- Provider computes a compile-time fingerprint of all exported function signatures.
- Every invocation loads script via compile-time path or active runtime resolver override.
- Runtime exported signature fingerprint must exactly match compile-time fingerprint.
- Mismatch fails invocation with an error before function execution.
- No resolver set: load compile-time script file.
- Resolver set and returns
Some: loadEntrySourcewithloadSourceWithIncludesand optional import resolver. - Resolver set and returns
None: fallback to compile-time script file.