Module Cmarkit.Meta

Abstract syntax tree node metadata.

type t

The type for abstract syntax tree node metadata.

val v : ?init:t -> ?id:string -> ?tloc:Tloc.t -> unit -> t

v ~init ?id ?tloc () has the values of ~init (defaults to none) overriden by specified arguments.

val none : t

none has Tloc.none for tloc and "" for id.

val id : t -> string

id m is a string identifier. It should be unique but there's no guarantee it will be. It can be used by HTML renderers to generate anchors.

val tloc : t -> Tloc.t

tloc m is the source location of the syntactic construct m is attached to.

Custom metadata

type 'a key

The type for custom metadata keys.

val key : unit -> 'a key

key () is a new metadata key.

val mem : 'a key -> t -> bool

mem k m is true iff k is bound in m.

val add : 'a key -> 'a -> t -> t

add k v m is m with key k bound to v.

val tag : unit key -> t -> t

tag k m is add k () m.

val rem : 'a key -> t -> t

rem k m is m with key k unbound in v.

val find : 'a key -> t -> 'a option

find k m the value of k in m, if any.