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
(* | |
Print a float using the engineering notation. | |
The representation is approximate in the sense that it does not always allow | |
to recover the original float by parsing the result. | |
nan | |
inf | |
-inf | |
0 |
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
<doc text="Type definitions for family trees"> | |
type tree = { | |
members : person list; | |
filiations : filiation list; | |
} | |
type filiation = { | |
parent : person_id; | |
child : person_id; |
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 quote ic = | |
let buf = Buffer.create 1000 in | |
Buffer.add_string buf "\ | |
let contents = | |
\""; | |
try | |
while true do | |
Buffer.add_string buf (String.escaped (input_line ic)); | |
Buffer.add_char buf '\n'; | |
done; |
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
cluster.name: elasticsearch_dev | |
path.data: ./data/ | |
path.logs: ./log/ | |
network.host: 0.0.0.0 |
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
(* ocamlfind ocamlc -c env.ml -package lwt.unix *) | |
(* | |
Wrapper around Lwt threads that allows | |
carrying an environment around, transparently. | |
Such an environment would typically consist of a request ID | |
that we can use in logs to identify all messages relating to | |
the same request received by the server. |
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
(* | |
Both calls to BatString.split and List.assoc below | |
raise Not_found. The stack trace shouldn't be empty | |
in either case, but it is empty under certain mysterious | |
circumstances for BatString.split. | |
#use "topfind";; | |
#require "batteries";; | |
*) |
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 t1 = { x: int; y: int } | |
type t2 = { x: int; z: int } | |
let f () = { x = 1; y = 0 } | |
(* no error *) | |
let () = | |
f () |> fun x -> | |
ignore x.x; | |
ignore x.y |
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
(* | |
One-time initialization. | |
Useful to create mutual dependencies between modules. | |
Usage: | |
(* Module A *) | |
let init_foo, foo = create "foo" |
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 json = [ | |
| `Bool of bool | |
| `Int of int | |
| `Object of (string * json) list | |
] | |
type _ path = | |
| Bool : bool path | |
| Int : int path | |
| Field : string * 'a path -> 'a path |
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
(* | |
An atdgen type for reading any number into an int. | |
`1.0` is the default output for the atd type float, which | |
we want to support but is not supported by the regular parser | |
for atd type int. | |
`1.0` will be read as the OCaml int `1` and written back as `1`. | |
The definition that goes into the .atd file is: |
OlderNewer