watch file generates an Arrow that adds a file to the dependency list without reading it. It can be useful for making file generation dependent on other files. For example :
let track_binary_update = watch Sys.argv.(0)
Which adds the generating binary to the list of dependencies.
Read a file and parse metadata in the header. If the metadata is invalid, the arrow will throw an error. The first module defines how to go from string to structured object (for example the module Yocaml_yaml which process Yaml) and the second one describes the parsed metadata (see: Metadata).
Applies a file as a template. (and replacing the metadata). Once the content has been transformed, the arrow returns a pair containing the metadata and the file content injected into the template. The first module describes how to make a metadata compliant with a template language (e.g. Mustache) and the second describes how to apply the template with variables.
val without_body : 'a->'a * string
When a template should be applied without body.
val collection :
'a listEffect.t->('a->(unit, 'b)t)->('b list->'c->'e)->('c, 'e)tEffect.t
Sometimes it is necessary to calculate a page according to other pages, for example to make an index of articles. With collection you can separate this procedure into 3 steps.
First, it executes an effect that acts on a list
Then it goes through the list of collected data and applies an arbitrary arrow to it.
Finally, it applies an aggregate function to the collected list.
For example, let's build our index by projecting the list of articles into the Articles metadata:
let index =
let open Build in
let* articles =
collection
(read_child_files "articles/" (with_extension "md"))
(fun source ->
track_binary_update
>>> Yocaml_yaml.read_file_with_metadata
(module Metadata.Article)
source
>>^ fun (x, _) -> x, article_destination source)
(fun x (meta, content) ->
x
|> Metadata.Articles.make
?title:(Metadata.Page.title meta)
?description:(Metadata.Page.description meta)
|> Metadata.Articles.sort_articles_by_date
|> fun x -> x, content)
in
create_file
(into destination "index.html")
(track_binary_update
>>> Yocaml_yaml.read_file_with_metadata
(module Metadata.Page)
"index.md"
>>> Yocaml_markdown.content_to_html ()
>>> articles
>>> Yocaml_mustache.apply_as_template
(module Metadata.Articles)
"templates/list.html"
>>> Yocaml_mustache.apply_as_template
(module Metadata.Articles)
"templates/layout.html"
>>^ Stdlib.snd)
;;
Included Arrow combinators
A build rule respects the interface of an Arrow Choice (which implies Category and Arrow, by construction), for ergonomic reasons, the combinators of the three classes are included in the module toplevel.
An alias of CORE.compose (to be iso with Haskell's approach). Even <<< looks like <% (it is an alias for the same function), they differ in their priorities. OCaml documentation of operators priorities
An alias of CORE.compose_left_to_right (to be iso with Haskell's approach). Even >>> looks like %> (it is an alias for the same function), they differ in their priorities. OCaml documentation of operators priorities