I’m very new to OCaml, and coming from other languages, I’m wondering if there’s some PPX which gives you efficient template strings. For example,
let name = "aria" in [%str{|Hello {name}|}]
would end up as “Hello aria”. Where the output from the PPX would be use Buffers to add the strings together (since I’ve heard that it’s better to do that than use ^)
let name = "aria" in
let buf = Buffer.create 20 in
Buffer.add_string buf "Hello";
Buffer.add_string buf name;
buf |> Buffer.to_bytes |> Bytes.to_string
Does something like this already exist? If it doesn’t exist, would you have any advice if I wanted to try and make it myself?
I’m not trying to generate HTML no. Honestly I just want to learn more about PPX either by reading the code of a library that already does what I want or by doing it myself…in which case I’d need a little help.