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 _ compare = | |
| Int: int compare | |
| Float: float compare | |
| Poly: 'a compare | |
let[@inline always] typed_compare (type a) (w:a compare) (x:a) (y:a) = | |
match w with | |
| Int -> Stdlib.compare (x:int) (y:int) | |
| Float -> Stdlib.compare (x:float) (y:float) | |
| Poly -> Stdlib.compare 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
let with_timeout timeout (f:unit -> 'b) = | |
let read, write = Unix.pipe () in | |
match Unix.fork () with | |
| 0 -> | |
let result = f () in | |
let chan = Unix.out_channel_of_descr write in | |
Marshal.to_channel chan result []; | |
Out_channel.flush chan; | |
Unix.close write; | |
exit 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
type t = < count: int > | |
let leak: t option Atomic.t = Atomic.make None | |
let stop = Atomic.make false | |
class virtual counter = object(self) | |
val mutable counter = -1 | |
method count = counter |
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 device_flush ppf = | |
let fs = Format.pp_get_formatter_out_functions ppf () in | |
fs.out_flush () | |
let force_break_hints ppf = | |
let margin = Format.pp_get_margin ppf () in | |
Format.pp_print_as ppf (margin+1) "" | |
let gentler_flush ppf = | |
force_break_hints ppf; device_flush ppf |
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 'a abstract | |
sig | |
type 'a x = X | |
type 'a t = A: 'a -> 'a x t | |
end with type 'a x = 'a abstract |
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 'a printer = Format.formatter -> 'a -> unit | |
type 'a rand = unit -> 'a | |
let flushed_list pr ppf x = | |
List.iter (Format.fprintf ppf "%a@." pr) x | |
module type testable = sig | |
type t | |
val pp: t printer |
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 _ data_cstr = .. | |
module type t = sig | |
type a | |
type _ data_cstr += Fmt: a data_cstr | |
end | |
type 'a data_format = (module t with type a = 'a) | |
let mk_data_format : type a. unit -> a data_format = fun () -> |
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 _ data_cstr = .. | |
type 'a data_format = { id: extension_constructor; cstr: 'a data_cstr} | |
type (_, _) eq = Eq : ('a, 'a) eq | |
type data_key = { is_eq: 'a 'b. 'a data_cstr -> 'b data_cstr -> ('a,'b) eq option } | |
let data_format_register : (extension_constructor, data_key) Hashtbl.t = Hashtbl.create 17 |
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
s = "א" * 100 # "א" is assigned |
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 e = .. | |
type e += A | B | C | D | E | F | |
let f = function | |
| A -> 1 | |
| B -> 2 | |
| C -> 3 | |
| D -> 4 | |
| E -> 5 |