Quantcast
Channel: OCaml - Topics tagged dune
Viewing all articles
Browse latest Browse all 521

Decoders in dune

$
0
0

I am currently working on some project that involves Ocaml’s build system Dune. However, in my work, there is some tasks that require taking a file (mainly its path) which contains some text written in a S-expression format. For example, for those familiar with defining and building rules with dune,

(rule (deps (file a) (glob *.cmi)) (action cat a))

By investigating the dune codebase, I have understood that there is a decoder (which is actually a monad) that is defined for a type 'a, so that when this decoder is a ran on a certain S-expression it returns the object of type 'a defined in this S-expression (if it is a valid one).

My question is how exactly one could use such a defined decoder on custom file (that is not a dune file that is automatically parsed by dune) in order to extract the information? I assume that one should first parse the file in order to extract the S-expression, but I don’t know if that is automatically done by the decoder.Preformatted text

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 521

Trending Articles