package grace
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=821df54882c9253eac69f47bcf3a71ffdc61c77fdae42587c32aada5b56cfeae
sha512=007afa83251da3ddecd874e120ea89dce0253c387a64a5fece69069d3486ec5eb6c82d6bf0febaf23dd322bd9eaadc2f7882e33f05a2e1fa18a41294e7dc3ba1
doc/grace/Grace/Source/index.html
Module Grace.SourceSource
Source is a file-like abstraction.
Grace provides the abstraction of a file called a 'source'.
There are several benefits with providing a in-memory abstraction of a sources:
- Virtual files: It is often useful to invent temporary files (e.g. test input, command line input, REPL input). By providing a in-memory abstraction, Grace provides the ability to create virtual files.
- Caching: Caching sources is useful in many situations (e.g. LSP semantic analysis, reporting multiple errors in a single file in a diagnostic reporter, etc).
type reader = {id : int;(*The unique identifier of the reader. Equality, comparison, hashing are all performed on this identifier.
*)name : string option;(*The name of the reader. The diagnostic render can use the name of the reader in place of a file path.
*)length : int;(*The length (in bytes) of the source.
*)unsafe_get : int -> char;(*
*)unsafe_get ireads theith byte without performing bounds checks.
}A reader denotes an arbitrary byte source (potentially backed by a file, buffer, socket, etc).
reader_name reader returns the name of the reader. If reader.name is None, then identifier reader.id (converted to a string) is returned.
type string_source = {name : string option;(*The name of a string source. The diagnostic render can use the name of a string source in place of a file path.
*)content : string;(*The content of a string source
*)
}An in-memory string source.
val hash_fold_string_source :
Ppx_hash_lib.Std.Hash.state ->
string_source ->
Ppx_hash_lib.Std.Hash.statetype t = [ | `File of string(*A file source specified by its filename.
*)| `String of string_source(*A in-memory string source.
*)| `Reader of reader(*A reader-backed source.
*)
]The type of sources.