├── README.markdown ├── images ├── merlin.png ├── ocp-browser.gif └── utop.png └── opam /README.markdown: -------------------------------------------------------------------------------- 1 | starterkit 2 | =========== 3 | 4 | This is a meta package intended for new opam switches and for new 5 | OCaml programmers. 6 | 7 | Get a switch ready with: 8 | 9 | ```shell 10 | $ opam install starterkit 11 | ``` 12 | 13 | It installs `lambda-term`, `ocp-indent`, `stringext`, `utop`, 14 | `ocp-index`, `merlin`, `ocamlfind`, `oasis`, `ocamlbuild`. 15 | 16 | # OCaml workflow 17 | 18 | Use `oasis` to get a project up and running quickly, example `_oasis` 19 | file: 20 | 21 | ```text 22 | OASISFormat: 0.4 23 | OCamlVersion: >= 4.02.0 24 | Name: opam_package_name 25 | Version: 0.1.0 26 | Maintainers: New OCaml programmer 27 | Homepage: http://my_coolsite.com 28 | Synopsis: Some short description 29 | Authors: Cool@me.com 30 | License: BSD-3-clause 31 | Plugins: META (0.4), DevFiles (0.4) 32 | AlphaFeatures: ocamlbuild_more_args 33 | 34 | Description: 35 | Some cool description 36 | 37 | # This is a comment and this below creates an binary program 38 | Executable 39 | Path: src 40 | BuildTools:ocamlbuild 41 | install: true 42 | MainIs: main.ml 43 | CompiledObject: native 44 | BuildDepends: package_one, package_two 45 | 46 | # Another comment, this builds a library called pg 47 | Library pg 48 | Path: src 49 | # oasis will figure out the dependencies, 50 | # Just list the modules you want public, 51 | # Note that there's no .ml, just give the name 52 | Modules: Pg 53 | CompiledObject: best 54 | BuildDepends: some_package, another_package 55 | 56 | # Here's one that uses C/C++ code, adapt as needed 57 | Library lib_with_c 58 | Path: src 59 | BuildTools:ocamlbuild 60 | install: true 61 | CClib: -L/usr/local/lib -lfoo -lbar -lstdc++ 62 | CCOpt: -g -Wall -std=c++11 -x c++ -I/usr/local/include 63 | NativeOpt: -cc g++ 64 | ByteOpt: -cc g++ 65 | Modules: Some_lib 66 | CompiledObject: best 67 | CSources: some_lib_stubs.c 68 | BuildDepends: opam_lib1, opam_lib2 69 | ``` 70 | 71 | Auto generate everything with: 72 | 73 | `oasis setup -setup-update dynamic` 74 | 75 | then a simple 76 | 77 | `make` builds your project. 78 | 79 | Use `ocp-browser` to show you type signatures/documentation of 80 | installed OCaml code: 81 | 82 | ```shell 83 | $ ocp-browser 84 | ``` 85 | 86 | ![](./images/ocp-browser.gif) 87 | 88 | Use `ocp-indent` to align your code, `vim/emacs` need to add code to 89 | their startup code. 90 | 91 | An example `~/.ocp-indent` file: 92 | 93 | ```text 94 | base = 2 95 | type = 2 96 | in = 0 97 | with = 0 98 | match_clause = 2 99 | max_indent = 4 100 | strict_with = never 101 | strict_else = always 102 | strict_comments = false 103 | align_ops = true 104 | align_params = auto 105 | syntax = lwt 106 | ``` 107 | 108 | Use `utop` for a great repl experience: 109 | 110 | ```shell 111 | $ utop 112 | ``` 113 | 114 | ![](./images/utop.png) 115 | 116 | Use `merlin` for code completion in your projects, just have a 117 | `.merlin` file in your project root and editor support from 118 | `vim/emacs`. 119 | 120 | ![](./images/merlin.png) 121 | 122 | Example `.merlin` file (`B` is for compiled built code path, `S` is 123 | for source) 124 | 125 | ```text 126 | B some_path1 127 | S some_path2 128 | PKG opam_pkg1 opam_pkg2 129 | FLG -w +a-4-40..42-44-45-48 130 | ``` 131 | 132 | Further material, emacs elisp and sample code found 133 | here:[So you're learning OCaml](http://hyegar.com/2015/10/20/so-youre-learning-ocaml/) 134 | -------------------------------------------------------------------------------- /images/merlin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fxfactorial/ocaml-starterkit/f0724f011a0fc1712551b64be88b45d9cf3fcfec/images/merlin.png -------------------------------------------------------------------------------- /images/ocp-browser.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fxfactorial/ocaml-starterkit/f0724f011a0fc1712551b64be88b45d9cf3fcfec/images/ocp-browser.gif -------------------------------------------------------------------------------- /images/utop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fxfactorial/ocaml-starterkit/f0724f011a0fc1712551b64be88b45d9cf3fcfec/images/utop.png -------------------------------------------------------------------------------- /opam: -------------------------------------------------------------------------------- 1 | # -*- conf -*- 2 | opam-version: "1.2" 3 | name: "starterkit" 4 | version: "1.1.0" 5 | maintainer: "Edgar Aroutiounian " 6 | authors: [ "Edgar Aroutiounian " ] 7 | license: "BSD-3-clause" 8 | homepage: "https://github.com/fxfactorial/ocaml-starterkit" 9 | depends: [ 10 | "lambda-term" 11 | "ocp-indent" 12 | "utop" 13 | "ocp-index" 14 | "merlin" 15 | "ocamlfind" 16 | "oasis" 17 | "ocamlbuild" 18 | "tuareg" 19 | "opam-publish" 20 | ] 21 | 22 | post-messages: [ 23 | "Welcome to OCaml coding, here's an example _oasis file" 24 | " 25 | 26 | OASISFormat: 0.4 27 | OCamlVersion: >= 4.04.0 28 | Name: opam_package_name 29 | Version: 0.1.0 30 | Maintainers: New OCaml programmer 31 | Homepage: http://my_coolsite.com 32 | Synopsis: Some short description 33 | Authors: Cool@me.com 34 | License: BSD-3-clause 35 | Plugins: META (0.4), DevFiles (0.4) 36 | AlphaFeatures: ocamlbuild_more_args 37 | 38 | Description: 39 | Some cool description 40 | 41 | # This is a comment and this below creates an binary program 42 | Executable 43 | Path: src 44 | BuildTools:ocamlbuild 45 | install: true 46 | MainIs: main.ml 47 | CompiledObject: native 48 | BuildDepends: package_one, package_two 49 | 50 | # Another comment, this builds a library called pg 51 | Library pg 52 | Path: src 53 | # oasis will figure out the dependencies, 54 | # Just list the modules you want public, 55 | # Note that there's no .ml, just give the name 56 | Modules: Pg 57 | CompiledObject: best 58 | BuildDepends: some_package, another_package 59 | 60 | # Here's one that uses C/C++ code, adapt as needed 61 | Library lib_with_c 62 | Path: src 63 | BuildTools:ocamlbuild 64 | install: true 65 | CClib: -L/usr/local/lib -lfoo -lbar -lstdc++ 66 | CCOpt: -g -Wall -std=c++11 -x c++ -I/usr/local/include 67 | NativeOpt: -cc g++ 68 | ByteOpt: -cc g++ 69 | Modules: Some_lib 70 | CompiledObject: best 71 | CSources: some_lib_stubs.c 72 | BuildDepends: opam_lib1, opam_lib2 73 | " 74 | 75 | "Auto generate everything with: 76 | 77 | `oasis setup -setup-update dynamic` 78 | 79 | then a simple 80 | 81 | `make` builds your project. 82 | 83 | " 84 | ] 85 | --------------------------------------------------------------------------------