{"id":22632198,"url":"https://github.com/sammi-turner/ocaml-examples","last_synced_at":"2025-10-05T22:19:23.925Z","repository":{"id":154780792,"uuid":"631509483","full_name":"sammi-turner/OCaml-Examples","owner":"sammi-turner","description":"This repo is designed to get you started with OCaml.","archived":false,"fork":false,"pushed_at":"2024-11-17T22:08:57.000Z","size":892,"stargazers_count":60,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-19T01:32:06.571Z","etag":null,"topics":["beginner-friendly","codewars-kata-solution","ocaml"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sammi-turner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-23T08:40:34.000Z","updated_at":"2024-11-30T11:08:27.000Z","dependencies_parsed_at":"2024-03-09T00:34:04.945Z","dependency_job_id":"cf9635a9-4842-45e8-88f4-03a501df07de","html_url":"https://github.com/sammi-turner/OCaml-Examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammi-turner%2FOCaml-Examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammi-turner%2FOCaml-Examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammi-turner%2FOCaml-Examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammi-turner%2FOCaml-Examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sammi-turner","download_url":"https://codeload.github.com/sammi-turner/OCaml-Examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230400616,"owners_count":18219831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beginner-friendly","codewars-kata-solution","ocaml"],"created_at":"2024-12-09T02:16:47.398Z","updated_at":"2025-10-05T22:19:23.921Z","avatar_url":"https://github.com/sammi-turner.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr\u003e\n\n# OCaml Examples\n\n\u003cbr\u003e\n\n## Install Opam\n\nTo install opam, follow [these instructions](https://ocaml.org/docs/up-and-running).\n\n\u003cbr\u003e\n\n## Building with Dune\n\nTo install, run\n\n```sh\nopam install dune\n```\n\nfollowed by\n\n```sh\nopam init\n```\n\n\u003cbr\u003e\n\n### Check version\n\nClose the terminal. Then re-open it to determine the version of dune you are running with\n\n```sh\ndune --version\n```\n\n\u003cbr\u003e\n\n### Quiet output\n\nTo prevent build progress reports from being printed before your programs run, create a global dune config file.\n\nOn unix systems, this will be located at\n\n```sh\n~/.config/dune/config\n```\n\nAdd the following code to the file, replacing 3.15 with the version number that you are running.\n\n```\n(lang dune 3.15)\n(display quiet)\n```\n\n\u003cbr\u003e\n\n### Useful shell function\n\nDune New Project (dnp)\n\n```sh\ndnp() {\n  dune init project $1 \u0026\u0026 cd $1 \u0026\u0026 dune build\n}\n```\n\n\u003cbr\u003e\n\n### Useful shell aliases\n\nDune Compile and Run (dcr)\n\n```sh\nalias dcr='dune build \u0026\u0026 dune exec ./bin/main.exe'\n```\n\nDune Compile (dc)\n\n```sh\nalias dc='dune build'\n```\n\nDune Run (dr)\n\n```sh\nalias dr='dune exec ./bin/main.exe'\n```\n\n\u003cbr\u003e\n\n## Alternative build system\n\n\u003cbr\u003e\n\n### Setting up ocamlbuild\n\n1. install ocamlbuild with\n\n```sh\nopam install ocamlbuild\n```\n\n2. install ocamlfind with\n\n```sh\nopam install ocamlfind\n```\n\n3. use opam to install any dependencies required by the project.\n\n4. in the project directory, create a _tags file with the following code\n\n```\ntrue: -traverse\n```\n\n5. Use the following functions and alias as shortcuts to compile and run your code.\n\nThe functions can be run with either zero parameters, or a list of dependencies.\n\nOCaml build (ob)\n\n```sh\nob() {\n  if [ $# -eq 0 ]; then\n    ocamlbuild -use-ocamlfind main.native\n  else\n    local pkgs=\"$*\"\n    ocamlbuild -use-ocamlfind -pkgs \"$pkgs\" main.native\n  fi\n}\n```\n\nOCaml build and run (obr)\n\n```sh\nobr() {\n  if [ $# -eq 0 ]; then\n    ocamlbuild -use-ocamlfind main.native \u0026\u0026 ./main.native\n  else\n    local pkgs=\"$*\"\n    ocamlbuild -use-ocamlfind -pkgs \"$pkgs\" main.native \u0026\u0026 ./main.native\n  fi\n}\n```\n\nRun OCaml binary (rob)\n\n```sh\nalias rob='./main.native'\n```\n\n\u003cbr\u003e\n\n### Bogus linting errors\n\nThe OCaml Platform extension for VSCode is configured to Dune rather than OCamlbuild, so using OCamlbuild projects with it will generate bogus linting errors.\n\nI don't know if this problem also occurs in terminal-based editors where an OCaml LSP is set up, but I dare say that it might.\n\nOne workaround for this problem is to use VSCodium instead of vscode, and to install the OCaml Platform Syntax extension rather than the OCaml Platform extension, but of course, this will only give you OCaml syntax highlighting, not linting or autocompletion.\n\n\u003cbr\u003e\n\n### Can I delete the build folder?\n\nYou can delete the build folder, but keeping it will make re-compilation faster.\n\n\u003cbr\u003e\n\n## OCaml Syntax Primer\n\nThe OCaml entry on [Learn X in Y Minutes](https://learnxinyminutes.com/docs/ocaml/) is very good.\n\n\u003cbr\u003e\n\n## Language Overview\n\nThe Read World OCaml site has a great [Guided Tour](https://dev.realworldocaml.org/guided-tour.html).\n\n\u003cbr\u003e\n\n## YouTube Tutorials\n\nFor video tutorials, I recommend Michael Ryan Clarkson's extensive [OCaml Programming](https://youtube.com/playlist?list=PLre5AT9JnKShBOPeuiD9b-I4XROIJhkIU) playlist.\n\n\u003cbr\u003e\n\n## Function Generation With LLMs\n\nAlthough I am still wary of using an LLM to create an entire project, they can still be useful for small code snippets.\n\nI have had good results with prompts using the following template\n\n```\nWrite a [name] function in OCaml that takes\n[name the parameters and their types] and returns\na [type] such that [describe what the function does].\n```\n\nAnother strategy is to provide the LLM with a list of function signatures for a particular utility or feature and ask the LLM to implement the function bodies, one by one, asking for your feedback at each step.\n\n\u003cbr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammi-turner%2Focaml-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsammi-turner%2Focaml-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammi-turner%2Focaml-examples/lists"}