Hydrodoc_meta



Metadata annotations

Metadata Annotations

These annotations come in two forms:

The global annotations are written in double brackets, whereas the local annotations are enclosed in single brackets.

Global Annotations

Hydro defines the following global annotations:

Local Annotations

User-Defined Mappings

Hydro has a simple, but quite powerful way for enhancing the built-in language mapping. Given that Hydro's native representation of an ICE type would be the OCaml type T, one can instruct hydrogen to use an alternate type T' instead, provided two functions exist that map T->T' and T'->T.

There are a few predefined enhancements:

In order to define you own enhancement, you need first to define the new mapping with the global annotation [["hydro:defmapping:NAME:..."]] , so you can later refer to it using ["hydro:mapping:NAME"] just as to the predefined mappings. The syntax to define the mapping is

[["hydro:defmapping:NAME:TYPE:TO:OF"]]

Here,

A simple example is

 [["hydro:defmapping:stringlist:string list:Array.to_list:Array.of_list"]] 

which can be applied to ICE string sequences in order to represent them as OCaml string lists. Note that we have to convert to and from arrays as Hydro's native representation of sequences are arrays.

As a special rule, applying a mapping to a struct implicitly also enables ["hydro:tuple"] , as it would be difficult to define the functions TO and OF for record types.

The definitions for the predefined mappings are:

[["hydro:defmapping:list:$1 list:Array.to_list:Array.of_list"]]
[["hydro:defmapping:option:$1 option:Hydro_lm.seq_to_option:Hydro_lm.option_to_seq"]]
[["hydro:defmapping:hashtbl:($1,$2)Hashtbl.t:Hydro_lm.dict_to_hashtbl:Hydro_lm.hashtbl_to_dict"]]
[["hydro:defmapping:strmap:($1,$2)Hydro_lm.strmap:Hydro_lm.dict_to_strmap:Hydro_lm.strmap_to_dict"]]
[["hydro:defmapping:complex:($1,$2)Hydro_lm.complex:Hydro_lm.pair_to_complex:Hydro_lm.complex_to_pair"]]
[["hydro:defmapping:identity:Hydro_types.identity:Hydro_lm.pair_to_identity:Hydro_lm.identity_to_pair"]]