package spin

  1. Overview
  2. Docs

Source file hello.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
(* Generated by: ocaml-crunch
   Creation date: Sat, 17 May 2025 12:17:10 GMT *)

module Internal = struct
  let d_0aa44a2573c0537533bdb01bd0da4e76 = "; Define a library named `hello` for our project.\n; The library does not have any dependency, so only the standard library\n; will be available in the modules of the `lib/` directory.\n;\n; Note that when a module with the same name as the library is defined,\n; it will be used as the top-level of our library. If it's not the case,\n; all of the modules in the directory will be exposed in a generated top-level.\n\n(library\n (name hello)\n (public_name hello)\n (libraries))\n"

  let d_11e62c26430cffb01ecba985b9465462 = "; This defines a new test.\n; The tests defined with `test` will be executed by Dune when running `dune test`.\n; The test runner is also available with the `make test` command for convenience.\n(test\n ; The name of the test must match the module name. \n ; Here for instance, the module `Hello_test` will be used.\n (name hello_test)\n ; The test executable links to the `hello` library defined in `lib/`\n ; and the `alcotest` library, installed through Opam.\n ; Alcotest is a well known test framework. There are many test frameworks\n ; in OCaml, but Alcotest is fairly standard and should be a good fit for \n ; most of your needs.\n (libraries alcotest hello))\n"

  let d_1e43c19a873ab87fae3a9e52eb062117 = "# Pin the version of ocamlformat. The formatting will fail if a version other than 0.18.0 is used.\n# This ensures that the formatting does not depend on the specific version of ocamlformat developers use.\nversion = 0.18.0\n# The conventional profile is fairly standard, but you can also try `sparse` or `janestreet`.\nprofile = conventional\n# Format the code source found in docstrings\nparse-docstrings = true\n# Insert break lines for docstring that are longer than 80 characters.\nwrap-comments = true\n"

  let d_260e6038aebfffb2879ff5f6adab67a8 = "# Hello\n\nThis project serves as a tutorial for your first OCaml project.\n\nIt will guide you through the typical project structure and OCaml development workflow.\nAlthough the organisation and tools used by the community vary, the ones used here are fairly standard and are the recommended way to work with OCaml with the [OCaml Platform](https://ocaml.org/platform/).\n\nIf you are already familiar with the setup and are looking to start a new project, you should probably use one of Spin's official template (list them with `spin ls`).\n\n## Setup your development environment\n\nYou need Opam, you can install it by following [Opam's documentation](https://opam.ocaml.org/doc/Install.html).\n\nWith Opam installed, you can install the dependencies in a new local switch with:\n\n```bash\nmake switch\n```\n\nOr globally, with:\n\n```bash\nmake deps\n```\n\nBoth of these commands will install the tools you typically need for you IDE (e.g. `ocaml-lsp-server`, `ocamlformat`).\nOnce the installation is complete, you can open the project in your IDE with the `vscode-ocaml-platform` extension.\n\nFinally, build the project with:\n\n```bash\nmake build\n```\n\n### Running Binary\n\nAfter building the project, you can run the main binary that is produced.\n\n```bash\nmake start\n```\n\n### Running Tests\n\nYou can run the test compiled executable:\n\n```bash\nmake test\n```\n\n### Building documentation\n\nDocumentation for the libraries in the project can be generated with:\n\n```bash\nmake doc\nmake servedoc\n```\n\n### Project Structure\n\nThe following snippet describes the project structure.\n\n```text\n.\n\226\148\156\226\148\128\226\148\128 bin/\n|   Source for the executable. This links to the library defined in `lib/`.\n\226\148\130\n\226\148\156\226\148\128\226\148\128 lib/\n|   Source for library of the project. \n\226\148\130\n\226\148\156\226\148\128\226\148\128 test/\n|   Unit tests and integration tests.\n\226\148\130\n\226\148\156\226\148\128\226\148\128 dune-project\n|   Dune file used to mark the root of the project and define project-wide parameters.\n|   For the documentation of the syntax, see https://dune.readthedocs.io/en/stable/dune-files.html#dune-project\n\226\148\130\n\226\148\156\226\148\128\226\148\128 LICENSE\n\226\148\130\n\226\148\156\226\148\128\226\148\128 Makefile\n|   Make file containing common development command.\n\226\148\130\n\226\148\156\226\148\128\226\148\128 README.md\n\226\148\130\n\226\148\148\226\148\128\226\148\128 hello.opam\n    Opam package definition.\n    To know more about creating and publishing opam packages, see https://opam.ocaml.org/doc/Packaging.html.\n```\n"

  let d_3d711faa31d29ab2bdf20958c1805bd3 = "(name hello)\n\n(description \"Tutorial template without any configuration\")\n\n(post_gen\n  (actions\n    (run make deps)\n    (run make build))\n  (message \"\240\159\142\129  Installing packages globally. This might take a couple minutes.\"))\n\n(example_commands\n  (commands\n    (\"make deps\" \"Download runtime and development dependencies.\")\n    (\"make build\" \"Build the dependencies and the project.\")\n    (\"make test\" \"Starts the test runner.\")))\n"

  let d_56038e89ed67492ee0c7d665a740df65 = "(* This file is the implementation of the Hello module.\n\n   The interface (aka exposed API, or signature) of the module is the hello.mli\n   counterpart.\n\n   When adding or changing the signature of a function here, the changes must be\n   reflected in the module interface as well. *)\n\n(* This defines a function named \"greet\" that takes an argument \"name\".\n\n   The infix operator \"^\" concatenates two strings, so the function will return\n   a new string \"Hello {name}!\" where \"{name}\" is the value of the name\n   argument. *)\nlet greet name = \"Hello \" ^ name ^ \"!\"\n"

  let d_5844e3656f9d17327f58ca2d9dd5f07c = "(* This file is the interface (aka exposed API, or signature) for the [Hello]\n   module. It only serves as documenting the module and selecting the functions\n   to expose. The actual implementation of the functions are located in the\n   module implementation [hello.ml]. *)\n\n(** This is a docstring, as it starts with \"(**\", as opposed to normal comments\n    that start with \"(*\".\n\n    The top-most docstring of the module should contain a description of the\n    module, what it does, how to use it, etc.\n\n    The function-specific documentation located below the function signatures. *)\n\nval greet : string -> string\n(** This is the docstring for the [greet] function.\n\n    You can read more about the ocamldoc syntax used to write docstrings here:\n\n    https://ocamlverse.github.io/content/documentation_guidelines.html\n\n    A typical documentation for this function would be:\n\n    Returns a greeting message.\n\n    {4 Examples}\n\n    {[ print_endline @@ greet \"Jane\" ]} *)\n"

  let d_7505884f45321563196598114784cbbc = "# This Makefile offers simpler frontend to the different tools for common development tasks.\n# You'll see that all of the commands are prepended by `opam exec -- ...` to run use the \n# tools installed in your Opam switch without having to run `eval $(opam env)`\n.DEFAULT_GOAL := all\n\nARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))\n$(eval $(ARGS):;@:)\n\n.PHONY: all\nall:\n\topam exec -- dune build --root . @install\n\n.PHONY: deps\ndeps: ## Install development dependencies\n\topam install -y dune-release ocamlformat utop ocaml-lsp-server\n\topam install --deps-only --with-test --with-doc -y .\n\n.PHONY: create_switch\ncreate_switch: ## Create an opam switch without any dependency\n\topam switch create . --no-install\n\n.PHONY: switch\nswitch: ## Create an opam switch and install development dependencies\n\topam install . --deps-only --with-doc --with-test\n\topam install -y dune-release ocamlformat utop ocaml-lsp-server\n\n.PHONY: lock\nlock: ## Generate a lock file\n\topam lock -y .\n\n.PHONY: build\nbuild: ## Build the project, including non installable libraries and executables\n\topam exec -- dune build --root .\n\n.PHONY: install\ninstall: all ## Install the packages on the system\n\topam exec -- dune install --root .\n\n.PHONY: start\nstart: all ## Run the produced executable\n\topam exec -- dune exec --root . bin/main.exe $(ARGS)\n\n.PHONY: test\ntest: ## Run the unit tests\n\topam exec -- dune runtest --root .\n\n.PHONY: clean\nclean: ## Clean build artifacts and other generated files\n\topam exec -- dune clean --root .\n\n.PHONY: doc\ndoc: ## Generate odoc documentation\n\topam exec -- dune build --root . @doc\n\n.PHONY: servedoc\nservedoc: doc ## Open odoc documentation with default web browser\n\topen _build/default/_doc/_html/index.html\n\n.PHONY: fmt\nfmt: ## Format the codebase with ocamlformat\n\topam exec -- dune build --root . --auto-promote @fmt\n\n.PHONY: watch\nwatch: ## Watch for the filesystem and rebuild on every change\n\topam exec -- dune build --root . --watch\n\n.PHONY: utop\nutop: ## Run a REPL and link with the project's libraries\n\topam exec -- dune utop --root . lib -- -implicit-bindings\n\n.PHONY: release\nrelease: all ## Run the release script \n\topam exec -- dune-release tag\n\topam exec -- dune-release distrib\n\topam exec -- dune-release publish distrib -y\n\topam exec -- dune-release opam pkg\n\topam exec -- dune-release opam submit --no-auto-open -y\n"

  let d_7972427c29238c9573be990c39191000 = "(executable\n ; The name of th executable.\n ; This is only the development name, but if user install the package, it will\n ; be accessible with the name defined in `public_name`\n (name main)\n (public_name hello)\n ; The executable depends on the library defined in `lib/`.\n ; This make the module `Hello` and its exposed functions available in\n ; all of the modules in this directory.\n (libraries hello))\n"

  let d_7e536236faf7138ba13470a237367e9d = "# bin\n\nNative project containing a binary.\n\n```bash\nspin new bin\n```\n"

  let d_96fc4a2ae8b33d76bd4fefdee44a06ec = "let () =\n  let greeting = Hello.greet \"world\" in\n  print_endline greeting\n"

  let d_b828cfa79c00cdbc974d302f50904778 = "; This defines some global environment configuration for Dune.\n; Here, we add some compiler flags in development to add warnings\n; on compilation, and fail the compilation when there are warnings.\n; If you want to deactivate some warning or error, you can add them\n; here, for instance `-w +A-48-42-44-4` will deactivate warning 4 in\n; addition to the ones already listed.\n\n(env\n (dev\n  (flags\n   (:standard -w +A-48-42-44 -warn-error +A-3))))\n"

  let d_bd608560839374d032ffe68d39ecc811 = "(* We open (or import) the Alcotest module. This makes all of the functions of\n   the Alcotest module available. *)\nopen Alcotest\n\n(* The Alcotest tests have the signature [unit -> unit], which means they take a\n   unit [()] (the ML equivalent of void, i.e. nothing) as the only argument, and\n   return a unit. *)\nlet test_greet () =\n  (* We call the [greet] function defined in our [hello] library with the\n     argument \"Tom\" and store the result in a [greeting] variable. *)\n  let greeting = Hello.greet \"Tom\" in\n  let expected = \"Hello Tom!\" in\n  (* The [check] and [string] come from Alcotest.\n\n     This line will make sure that [expected] and [greeting] have the same\n     value, or fail. *)\n  check string \"same string\" expected greeting\n\n(* This defined a new test suite.\n\n   A test suite in Alcotest is a list of (name, flag, test_function)*)\nlet suite = [ (\"can greet\", `Quick, test_greet) ]\n\n(* This line runs the test runner.\n\n   We define the name of the test runner, here \"hello\", and the different test\n   suites to run. Here, there's only one test suite called \"Hello\". *)\nlet () = Alcotest.run \"hello\" [ (\"Hello\", suite) ]\n"

  let d_c32a5545a2bdec4fee54ee09a7bcb8dc = "(lang dune 2.0)\n; The line above is the version of the syntax, not the actual version of the Dune binary\n; used. All of the Dune version after 2.0 will be retro-compatible.\n\n; The name of the Dune project. Not to be confused with the name of the package,\n; which is defined below: they can be different.\n(name hello)\n\n; The URL where the documentation is deployed.\n; If you release the package with dune-release (see `release` in the Makefile), \n; it will ask you to deploy the documentation at this address.\n(documentation \"https://username.github.io/hello/\")\n\n; The remote repository where the sources are hosted. This is used by opam, for instance\n; to add a link to the repository in the package page at `opam.ocaml.org`.\n(source\n (github username/hello))\n\n; The license of the project.\n(license ISC)\n\n; The names of the authors of the project, typically, all of the main contributors.\n(authors \"Your name\")\n\n; The names of the current maintainers of the project.\n(maintainers \"Your name\")\n\n; This tells dune to generate the `.opam` files for each package listed below.\n; If you prefer to manage your opam files yourself, you can delete this line and\n; edit the opam files directly.\n; If you need to add a field in the opam file that is not handled by dune, you can also\n; create a `hello.opam.template` file with the additionnal fields you'd like to generate.\n(generate_opam_files true)\n\n; This is used to generate the `hello.opam` file.\n(package\n (name hello)\n (synopsis \"A short description of the project\")\n (description \"A short description of the project\")\n (depends\n  (ocaml\n   (>= 4.08.0))\n  dune\n  ; You can tag dependencies with `:with-test`, `:with-doc`, or `:build`.\n  ; This will be used by the different tools and users that read the opam metadata.\n  ; For instance, users that want to install your package without the test will do\n  ; do so without the `--with-test` in the `opam install` command. But the CI, which\n  ; needs to run the unit tests, will run `opam install . --with-test`.\n  (alcotest :with-test)\n  (odoc :with-doc)))\n"

  let d_d494ac346a3f8fcc17af529747d4bda1 = "# This file is generated by dune, edit dune-project instead\nopam-version: \"2.0\"\nsynopsis: \"A short description of the project\"\ndescription: \"A short description of the project\"\nmaintainer: [\"Your name\"]\nauthors: [\"Your name\"]\nlicense: \"ISC\"\nhomepage: \"https://github.com/username/hello\"\ndoc: \"https://username.github.io/hello/\"\nbug-reports: \"https://github.com/username/hello/issues\"\ndepends: [\n  \"ocaml\" {>= \"4.08.0\"}\n  \"dune\"\n  \"alcotest\" {with-test}\n  \"odoc\" {with-doc}\n]\nbuild: [\n  [\"dune\" \"subst\"] {pinned}\n  [\n    \"dune\"\n    \"build\"\n    \"-p\"\n    name\n    \"-j\"\n    jobs\n    \"@install\"\n    \"@runtest\" {with-test}\n    \"@doc\" {with-doc}\n  ]\n]\ndev-repo: \"git+https://github.com/username/hello.git\"\n"

  let d_d524ff976af0bb15d69adb6fa5a9e521 = "# Dune generated files\n_build/\n*.install\n\n# Merlin configuring file for Vim and Emacs\n.merlin\n\n# Local OPAM switch\n_opam/\n"

  let d_e18c36fb04e9de2b5fe242bac33f7a81 = "ISC License\n\nCopyright (c) 2021 Your name\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE."

  let d_e6c7fb43d9948bb073e4b2e3b584c16b = "(** Main entry point for our application.\n\n    This is left empty intentionnally, because executables should not have any\n    interfaces. *)\n"

  let file_chunks = function
    | "README.md" | "/README.md" -> Some [ d_7e536236faf7138ba13470a237367e9d; ]
    | "spin" | "/spin" -> Some [ d_3d711faa31d29ab2bdf20958c1805bd3; ]
    | "template/.gitignore" | "/template/.gitignore" -> Some [ d_d524ff976af0bb15d69adb6fa5a9e521; ]
    | "template/.ocamlformat" | "/template/.ocamlformat" -> Some [ d_1e43c19a873ab87fae3a9e52eb062117; ]
    | "template/LICENSE" | "/template/LICENSE" -> Some [ d_e18c36fb04e9de2b5fe242bac33f7a81; ]
    | "template/Makefile" | "/template/Makefile" -> Some [ d_7505884f45321563196598114784cbbc; ]
    | "template/README.md" | "/template/README.md" -> Some [ d_260e6038aebfffb2879ff5f6adab67a8; ]
    | "template/bin/dune" | "/template/bin/dune" -> Some [ d_7972427c29238c9573be990c39191000; ]
    | "template/bin/main.ml" | "/template/bin/main.ml" -> Some [ d_96fc4a2ae8b33d76bd4fefdee44a06ec; ]
    | "template/bin/main.mli" | "/template/bin/main.mli" -> Some [ d_e6c7fb43d9948bb073e4b2e3b584c16b; ]
    | "template/dune" | "/template/dune" -> Some [ d_b828cfa79c00cdbc974d302f50904778; ]
    | "template/dune-project" | "/template/dune-project" -> Some [ d_c32a5545a2bdec4fee54ee09a7bcb8dc; ]
    | "template/hello.opam" | "/template/hello.opam" -> Some [ d_d494ac346a3f8fcc17af529747d4bda1; ]
    | "template/lib/dune" | "/template/lib/dune" -> Some [ d_0aa44a2573c0537533bdb01bd0da4e76; ]
    | "template/lib/hello.ml" | "/template/lib/hello.ml" -> Some [ d_56038e89ed67492ee0c7d665a740df65; ]
    | "template/lib/hello.mli" | "/template/lib/hello.mli" -> Some [ d_5844e3656f9d17327f58ca2d9dd5f07c; ]
    | "template/test/dune" | "/template/test/dune" -> Some [ d_11e62c26430cffb01ecba985b9465462; ]
    | "template/test/hello_test.ml" | "/template/test/hello_test.ml" -> Some [ d_bd608560839374d032ffe68d39ecc811; ]
    | _ -> None

  let file_list = [ "README.md"; "spin"; "template/.gitignore"; "template/.ocamlformat"; "template/LICENSE"; "template/Makefile"; "template/README.md"; "template/bin/dune"; "template/bin/main.ml"; "template/bin/main.mli"; "template/dune"; "template/dune-project"; "template/hello.opam"; "template/lib/dune"; "template/lib/hello.ml"; "template/lib/hello.mli"; "template/test/dune"; "template/test/hello_test.ml"; ]
end

let file_list = Internal.file_list

let read name =
  match Internal.file_chunks name with
  | None -> None
  | Some c -> Some (String.concat "" c)

let hash = function
  | "README.md" | "/README.md" -> Some "7e536236faf7138ba13470a237367e9d"
  | "spin" | "/spin" -> Some "3d711faa31d29ab2bdf20958c1805bd3"
  | "template/.gitignore" | "/template/.gitignore" -> Some "d524ff976af0bb15d69adb6fa5a9e521"
  | "template/.ocamlformat" | "/template/.ocamlformat" -> Some "1e43c19a873ab87fae3a9e52eb062117"
  | "template/LICENSE" | "/template/LICENSE" -> Some "e18c36fb04e9de2b5fe242bac33f7a81"
  | "template/Makefile" | "/template/Makefile" -> Some "7505884f45321563196598114784cbbc"
  | "template/README.md" | "/template/README.md" -> Some "260e6038aebfffb2879ff5f6adab67a8"
  | "template/bin/dune" | "/template/bin/dune" -> Some "7972427c29238c9573be990c39191000"
  | "template/bin/main.ml" | "/template/bin/main.ml" -> Some "96fc4a2ae8b33d76bd4fefdee44a06ec"
  | "template/bin/main.mli" | "/template/bin/main.mli" -> Some "e6c7fb43d9948bb073e4b2e3b584c16b"
  | "template/dune" | "/template/dune" -> Some "b828cfa79c00cdbc974d302f50904778"
  | "template/dune-project" | "/template/dune-project" -> Some "c32a5545a2bdec4fee54ee09a7bcb8dc"
  | "template/hello.opam" | "/template/hello.opam" -> Some "d494ac346a3f8fcc17af529747d4bda1"
  | "template/lib/dune" | "/template/lib/dune" -> Some "0aa44a2573c0537533bdb01bd0da4e76"
  | "template/lib/hello.ml" | "/template/lib/hello.ml" -> Some "56038e89ed67492ee0c7d665a740df65"
  | "template/lib/hello.mli" | "/template/lib/hello.mli" -> Some "5844e3656f9d17327f58ca2d9dd5f07c"
  | "template/test/dune" | "/template/test/dune" -> Some "11e62c26430cffb01ecba985b9465462"
  | "template/test/hello_test.ml" | "/template/test/hello_test.ml" -> Some "bd608560839374d032ffe68d39ecc811"
  | _ -> None

let size = function
  | "README.md" | "/README.md" -> Some 69
  | "spin" | "/spin" -> Some 428
  | "template/.gitignore" | "/template/.gitignore" -> Some 122
  | "template/.ocamlformat" | "/template/.ocamlformat" -> Some 500
  | "template/LICENSE" | "/template/LICENSE" -> Some 739
  | "template/Makefile" | "/template/Makefile" -> Some 2354
  | "template/README.md" | "/template/README.md" -> Some 2285
  | "template/bin/dune" | "/template/bin/dune" -> Some 403
  | "template/bin/main.ml" | "/template/bin/main.ml" -> Some 74
  | "template/bin/main.mli" | "/template/bin/main.mli" -> Some 141
  | "template/dune" | "/template/dune" -> Some 444
  | "template/dune-project" | "/template/dune-project" -> Some 2052
  | "template/hello.opam" | "/template/hello.opam" -> Some 699
  | "template/lib/dune" | "/template/lib/dune" -> Some 469
  | "template/lib/hello.ml" | "/template/lib/hello.ml" -> Some 565
  | "template/lib/hello.mli" | "/template/lib/hello.mli" -> Some 974
  | "template/test/dune" | "/template/test/dune" -> Some 657
  | "template/test/hello_test.ml" | "/template/test/hello_test.ml" -> Some 1141
  | _ -> None
OCaml

Innovation. Community. Security.