Skip to content

Instantly share code, notes, and snippets.

ocamlc x.ml
File "x.ml", line 30, characters 16-28:
Error: Unbound value Rep.dispatch
module type MESSAGE =
sig
type obj
type variant
val make : unit -> obj
(* encapsulate object in a variant type *)
val convert : obj -> variant
val print : obj -> unit
end
@raphael-proust
raphael-proust / parse_int
Created October 2, 2011 21:00
Int parsing with radix
(*/!\ known bugs and shortcomings:
- lacks integer overflow check,
- lacks sign parsing (can't parse negative ints)
- exceptions are not helpfull
- code is ugly
- should benchmark parse_int against parse_int_
*)
let int_of_char c = match c with
@raphael-proust
raphael-proust / dnd5e_damage.ml
Created December 14, 2017 01:50
DnD5e hit and damage calculation using a monad to simulate dice
module type POSSIBLES = sig
(* A monad to simulate all possible outcomes of a non-deterministic
* operation with discrete outcomes such as dice rolling. *)
type 'a t
(** [return x] is the possible outcomes for an operation where [x] is the
* only possible outcome. *)
val return: 'a -> 'a t
@raphael-proust
raphael-proust / wip.diff
Created September 18, 2020 07:59
WIP for ERANGE handling
diff --git a/src/unix/lwt_unix.cppo.ml b/src/unix/lwt_unix.cppo.ml
index 89bb84228..69ef1a45d 100644
--- a/src/unix/lwt_unix.cppo.ml
+++ b/src/unix/lwt_unix.cppo.ml
@@ -1543,29 +1543,48 @@ let getpwnam name =
else
run_job (getpwnam_job name)
-external getgrnam_job : string -> Unix.group_entry job = "lwt_unix_getgrnam_job"
+let retry_after_erange name trying =