Hello. I am new to OCaml and was researching OCaml SQL libraries and stumbled upon GitHub - Gopiandcode/petrol: Petrol's an OCaml SQL API made to go FAST..
There is an example in the README of that project:
(* declare a table *)
let example_table, Expr.[name; age] =
StaticSchema.declare_table schema ~name:"example"
Schema.[
field "name" ~ty:Type.text;
field "age" ~ty:Type.int
]
I don’t understand what is going on with Expr.[name; age]
. At first I thought this was a local open. But it appears that name
and age
are being introduced, i.e. newly assigned to, so I don’t understand what the Expr.
local open would accomplish. As far as I can tell, neither name
nor age
are existing types or values inside the Expr
module.
(I cloned the project and tried to run the tests, but I couldn’t figure out how to. dune test
doesn’t seem to do anything).
Would someone be able to help me understand this OCaml syntax? Thanks.