【Q】Tutorial for extended syntax?

Hello there!

As an OCaml / FP noob, I recently discovered an OCaml web framework - you probably familiar with - Dream, and when I look into the example code, I found that they use a quite different syntax from native OCaml? For example the direct use of HTML tags (<something> </something>).

Even though I’m still new to OCaml syntax and only know about 20% of OCaml’s syntax, I know that this is not pure OCaml.

Also, I know the existence of Coq and ReasonML, both of them are based on OCaml but have different syntax.

Since the only language I currently know about is CPython and never leant any functional programming language before, I’m confused and not familiar with this at all.

But I’m really interested in these features(packages?), yet could not find as many learning resources as Python. I did find some books about OCaml but as a person without any CS knowledge, I found them hard to read (less enjoyable than Youtube tutorial videos).

Any advice? Thanks a lot. :blush:

(I don’t know exactly what camlp4 does but I heard that it’s used to create new syntax so I just added it to the tags randomly)

Hi !
Welcome to OCaml !

Coq and ReasonML are very different. Coq is a proof assistant that is implemented partly in OCaml. Because of this, it has similarities to OCaml, but it is not based on it, it has very different uses and principles.
ReasonML is an alternative syntax for OCaml. This means it uses the same compiler and toolchain, except the ones that are syntax aware (like a formatter). You can even mix Reason and OCaml files in the same project.
Reason was invented because some people believed OCaml syntax was too weird and that javascript devs would have an easier time learning OCaml if the syntax was closer to what they already knew. Since you are not a javascript dev, you do not need Reason :slight_smile:

Dream does have some non-standard syntax, but it is not provided by camlp4. camlp4 is a way to add new syntax to OCaml, but it is hard to use with other tools such as editors extensions, so it has been deprecated in favor of PPX, which is what Dream uses.
You can find an explanation of PPX here : Preprocessors and PPXs · OCaml Tutorials.

As for general learning ressources, I am not the best person to ask. I have heard good things about the Cornell course : OCaml Programming: Correct + Efficient + Beautiful — OCaml Programming: Correct + Efficient + Beautiful
Its true that there is not as much ressources than for Python, and I am not aware of any video tutorial.


Thanks a lot! I thought ReasonML was something similar to Coq and did not aware that OCaml had preprocessors. I’ll dig into it and probably make some tutorial videos while learning this language for people from my country, cuz there’s even less learning resources in my country :stuck_out_tongue_winking_eye: Thanks for explaining! :smiling_face:


Thats a great idea !

1 Like