This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Rresult | |
include R | |
type ('a, 'b) result_lwt = ('a, 'b) result Lwt.t | |
let ok x = Lwt.return @@ Ok x | |
let error e = Lwt.return @@ Error e | |
let return = ok | |
let bind x f = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Put this in ~/.ocamlinit to be able to toggle requiring ;; on and off *) | |
let toggle_semi = | |
let original = !UTop.parse_toplevel_phrase in | |
let no_semi str eos_is_error = original (str ^ ";;") eos_is_error in | |
let semi = ref true in | |
fun () -> | |
UTop.parse_toplevel_phrase := if !semi then no_semi else original; | |
semi := not !semi | |
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ocamlbuild -classic-display -use-ocamlfind -package ppx_import,ppx_deriving.std test.cma | |
ocamlfind ocamldep -package ppx_import,ppx_deriving.std -modules test.mli > test.mli.depends | |
ocamlfind ocamlc -c -package ppx_import,ppx_deriving.std -o test.cmi test.mli | |
ocamlfind ocamldep -package ppx_import,ppx_deriving.std -modules test.ml > test.ml.depends | |
ocamlfind ocamlc -c -package ppx_import,ppx_deriving.std -o test.cmo test.ml | |
+ ocamlfind ocamlc -c -package ppx_import,ppx_deriving.std -o test.cmo test.ml | |
File "test.ml", line 1, characters 19-25: | |
Error: Unbound module Test | |
Command exited with code 2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -ex | |
echo 'yes' | sudo apt-add-repository ppa:chris-lea/zeromq | |
sudo apt-get update | |
sudo apt-get install libzmq3-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* In the context of BatSet and BatSet.Make *) | |
module Infix = struct | |
let ( <-- ) s x = add x s | |
let ( < ) a b = not (equal a b) && subset a b | |
let ( > ) b a = not (equal a b) && subset a b | |
let ( <= ) a b = subset a b | |
let ( >= ) b a = subset a b | |
let ( - ) a b = diff a b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type S = sig | |
type t | |
end | |
module type Sout = sig | |
type a | |
type b | |
type t = A of a | B of b | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type read | |
type write | |
type no | |
type (_, _, _) t = | |
| Read : ('i -> 'e) -> ('i, 'e, (read * no)) t | |
| Write : ('i -> 'e -> unit) -> ('i, 'e, (no * write)) t | |
| ReadWrite : ('i -> 'e) * ('i -> 'e -> unit) -> ('i, 'e, (read * write)) t | |
let make_ro get = Read get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ( >>= ) = Lwt.( >>= ) | |
let ( >|= ) = Lwt.( >|= ) | |
external identity : 'a -> 'a = "%identity" | |
module type Src_sig = sig | |
type t | |
val read_bytes : t -> size:int -> offset:int -> string option Lwt.t | |
val write_bytes : t -> string -> offset:int -> unit Lwt.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ( >>= ) = Lwt.( >>= ) | |
let promise f x = | |
let mbox = Lwt_mvar.create_empty () in | |
Lwt.async ( | |
fun () -> | |
f x >>= fun y -> | |
Lwt_mvar.put mbox y | |
); | |
mbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Ocamlbuild_plugin | |
let () = dispatch begin function | |
| After_rules -> | |
rule "atdgen: .atd -> _t.ml*, _j.ml*, _v.ml*" | |
~prods:["%_t.ml";"%_t.mli";"%_j.ml";"%_j.mli";"%_v.ml";"%_v.mli";] | |
~dep:"%.atd" | |
(begin fun env build -> | |
let atdgen = "atdgen" in | |
Seq [ |