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 w = Weak.create 2 | |
let gen () = | |
let x = "Hello" ^ string_of_int (Random.int 50) in | |
Weak.set w 0 (Some x); | |
let f () = () in | |
Gc.finalise_last (fun () -> ignore (Sys.opaque_identity x)) f; | |
f | |
let forgetful_gen2 () = |
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 t = | |
| Constant of 'a | |
(** [Constant x] is a normal value *) | |
| Input of (int -> 'a t) | |
(** [Input x] is a value which is blocked on an missing (int) user input *) | |
let pure x = Constant x | |
(** [int: int t] is the core extension of ['a t] compared to normal values ['a]: | |
it is a concrete representation of the action "reading an integer on stdin" |
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[@tail_mod_cons] rec split escape_char char start pos s = | |
if pos >= String.length s then | |
[String.sub s start (String.length s - start)] | |
else | |
let c = s.[pos] in | |
if c = char then | |
(String.sub s start (pos-start)) :: split escape_char char (pos+1) (pos+1) s | |
else | |
let pos = if c = escape_char then pos + 2 else pos + 1 in | |
split escape_char char start pos s |
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 Url = struct let v2 = "v2" end | |
let fwd_v2 target = (target, Url.v2 ^ target) | |
let pp_ocaml_version ppf (mj, mn) = | |
if mj >= 5 then Format.fprintf ppf "%d.%d" mj mn | |
else Format.fprintf ppf "%d.%02d" mj mn | |
let notes_redirections v = | |
let fwd_v2_notes x = |
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 pair = sig type a type b end | |
module type S = functor (Pair:sig include pair type b = a end) -> sig | |
open Pair | |
type either = Left of a | Right of b | |
end | |
module R = struct | |
type a = A | |
type b = a |
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 Unit: sig | |
type 'a t | |
val magic: 'a t -> 'b t | |
type m type s | |
val m: m t | |
val s: s t | |
val (+): 'a t -> 'a t -> 'a t | |
val ( * ): 'a t -> 'b t -> ('a * 'b) t | |
end = struct | |
type 'a t =float |
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 _ calculi_register = .. | |
type 'a c = | |
| Core of 'a | |
| Ext: 'b calculi_register *'b -> 'a c | |
type mixed_eval = { eval: 'a. 'a calculi_register -> 'a -> 'a c } | |
module type ext_calculus = sig | |
type core |
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 maybe_reduce | |
(MonoidElement.Constructor ((module Monoid1) as monoid1, element1)) | |
(MonoidElement.Constructor ((module Monoid2) as monoid2, element2)) = | |
let element1_is_unit = Monoid1.eq element1 Monoid1.unit in | |
let element2_is_unit = Monoid2.eq element2 Monoid2.unit in | |
let same_monoid = Type_equal.Id.same_witness Monoid1.t Monoid2.t in | |
match element1_is_unit, element2_is_unit, same_monoid with | |
| true, _, _ -> Reduced (MonoidElement.Constructor (monoid2, element2)) | |
| _, true, _ -> Reduced (MonoidElement.Constructor (monoid1, element1)) | |
| _, _, Some eq -> |
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 L = struct | |
type 'args t = | |
| [] : unit t | |
| (::): 'a * 'b t -> ('a -> 'b) t | |
end | |
let rec print_list: type args result. | |
Format.formatter -> args -> args L.t -> unit = | |
fun ppf print -> function | |
| [] -> () |
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,'b,'c) skel = | |
| A of 'a | |
| B of 'b | |
| C of 'c | |
type 'a disabled = | | |
type 'a enabled = 'a | |
module Make(X:sig type 'a a type 'a b type 'a c end) = struct | |
type ('a,'b,'c) t = ('a X.a, 'b X.b, 'c X.c) skel |
NewerOlder