ocamlbyexample icon indicating copy to clipboard operation
ocamlbyexample copied to clipboard

Learn Ocaml by reading code examples

Results 19 ocamlbyexample issues
Sort by recently updated
recently updated
newest added

you can do early returns in ocaml by throwing exceptions and catching them, which is what `Core.with_return` does

```ocaml (* an example with type variables that produces a bug *) let map (x: 'a * 'a) (f:'a -> 'b) : ('b * 'b) = let x1, x2 =...

```ocaml module A = struct type t = int end module type A = module type of A let a = (module A : A) module B = (val a...

you can dump any AST by doing `ocamlfind ppx_tools/dumpast your_file.ml`

Currently the syntax highlighting is done via a client-side highlighter downloaded from a CDN. There are problems with this approach: * `` is not supported; text is black on black...

Learning how to read compiler errors is a must

I think this library did a faux pas. It shouldn't have separated the comments from the text. It's just too much of a pain to create a chapter due to...

analyze a single file without its `.mli`: ``` $ utop # #use_output "dune ocaml top-module path/to/module.ml";; ```

cf https://github.com/mirage/alcotest/pull/365 > You can then declare your test and link with Alcotest: > `(test (libraries alcotest …) …)`.

``` utop # let a = lazy "prout";; val a : string lazy_t = lazy "prout" utop # Lazy.force a;; - : string = "prout" ```