From 6cd4269eeedf4fb13af254527a14ca4c66f2940f Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 19 Sep 2023 16:07:18 +0200 Subject: [PATCH] Add OCaml --- README.md | 16 ++++++++++++++++ ocaml/.gitignore | 1 + ocaml/.ocamlformat | 1 + ocaml/bin/dune | 4 ++++ ocaml/bin/main.ml | 3 +++ ocaml/dune-project | 24 ++++++++++++++++++++++++ ocaml/example.opam | 0 ocaml/lib/dune | 3 +++ ocaml/lib/hello.ml | 1 + ocaml/test/dune | 3 +++ ocaml/test/test.ml | 3 +++ 11 files changed, 59 insertions(+) create mode 100644 ocaml/.gitignore create mode 100644 ocaml/.ocamlformat create mode 100644 ocaml/bin/dune create mode 100644 ocaml/bin/main.ml create mode 100644 ocaml/dune-project create mode 100644 ocaml/example.opam create mode 100644 ocaml/lib/dune create mode 100644 ocaml/lib/hello.ml create mode 100644 ocaml/test/dune create mode 100644 ocaml/test/test.ml diff --git a/README.md b/README.md index e4cd72b..cac4207 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ - [C](#c) - [C++](#c-1) +- [OCaml](#ocaml) - [Typescript](#typescript) ## C @@ -28,6 +29,21 @@ Copy and paste [`cpp/`](./cpp/) directory, and you should be good to go! > Note that in headers, the syntax is `PROJECTNAME_FILENAME_HPP` +## OCaml + +Copy and paste [`ocaml/`](./ocaml/) directory, and you should be good to go! + +- Remember to change values in the [`dune-project`](./ocaml/dune-project). +- **Run `dune exec example` to run the program.** +- **Run `dune runtest` to run tests.** + +> Example of custom repository source: +> +> ```dune +> (source +> (uri https://dev.example.com/project.git)) +> ``` + ## Typescript Copy and paste [`typescript/`](./typescript/) directory, and you should be good to go! diff --git a/ocaml/.gitignore b/ocaml/.gitignore new file mode 100644 index 0000000..a485625 --- /dev/null +++ b/ocaml/.gitignore @@ -0,0 +1 @@ +/_build diff --git a/ocaml/.ocamlformat b/ocaml/.ocamlformat new file mode 100644 index 0000000..0619e80 --- /dev/null +++ b/ocaml/.ocamlformat @@ -0,0 +1 @@ +profile = janestreet diff --git a/ocaml/bin/dune b/ocaml/bin/dune new file mode 100644 index 0000000..127e38d --- /dev/null +++ b/ocaml/bin/dune @@ -0,0 +1,4 @@ +(executable + (public_name example) + (name main) + (libraries example)) diff --git a/ocaml/bin/main.ml b/ocaml/bin/main.ml new file mode 100644 index 0000000..d2a8d5d --- /dev/null +++ b/ocaml/bin/main.ml @@ -0,0 +1,3 @@ +open Example.Hello + +let () = print_endline hello_world diff --git a/ocaml/dune-project b/ocaml/dune-project new file mode 100644 index 0000000..23a6369 --- /dev/null +++ b/ocaml/dune-project @@ -0,0 +1,24 @@ +(lang dune 3.10) + +(name example) + +(generate_opam_files true) + +(source + (github username/reponame)) + +(authors "YOU") + +(maintainers "YOU") + +(license AGPL-3.0-or-later) + +(package + (name example) + (synopsis "A short synopsis") + (description "A longer description") + (depends ocaml dune) + (tags + (topics "to describe" your project))) + +; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project diff --git a/ocaml/example.opam b/ocaml/example.opam new file mode 100644 index 0000000..e69de29 diff --git a/ocaml/lib/dune b/ocaml/lib/dune new file mode 100644 index 0000000..4f61be2 --- /dev/null +++ b/ocaml/lib/dune @@ -0,0 +1,3 @@ +(library + (name example) + (modules hello)) diff --git a/ocaml/lib/hello.ml b/ocaml/lib/hello.ml new file mode 100644 index 0000000..2d1434d --- /dev/null +++ b/ocaml/lib/hello.ml @@ -0,0 +1 @@ +let hello_world = "Hello, world!" diff --git a/ocaml/test/dune b/ocaml/test/dune new file mode 100644 index 0000000..faf9d8d --- /dev/null +++ b/ocaml/test/dune @@ -0,0 +1,3 @@ +(test + (name test) + (libraries example)) diff --git a/ocaml/test/test.ml b/ocaml/test/test.ml new file mode 100644 index 0000000..8b04310 --- /dev/null +++ b/ocaml/test/test.ml @@ -0,0 +1,3 @@ +open Example.Hello + +let () = assert ("Hello, world!" = hello_world)