Skip to content

Instantly share code, notes, and snippets.

type _ value =
| Any : 'a value
| Float : float -> float value
| String : string -> string value
let print_string_value x =
match x with
| Any -> ()
type _ value =
| Any : 'a value
| String : string -> string value
| Float : float -> float value
let print_string_value : 'a . 'a value -> unit =
function
| Any -> ()
module Type = struct
type _ t =
| Bool : bool t
| Int : int t
| Float : float t
| Tuple : (_, 't) tuple -> 't t
and (_, _) tuple =
| Nil : ('t, 't) tuple
@gsg
gsg / crash.ml
Last active August 29, 2015 14:17
(* compile with -rectypes *)
type (_, _) t =
| Nil : ('t, 't) t
| Cons : ('t -> 'a) * ('r, 't) t -> (('a -> 'r), 't) t
(* replace the _ here with b -> no crash *)
let test : type a b . a -> (_, a) t -> unit =
fun value -> function
| Nil -> ()
type _ t =
| IntLit : int -> int t
| BoolLit : bool -> bool t;;
let eval : type a . a t -> (a * a) list =
fun term ->
List.map (fun x -> x, x) ((match term with
| IntLit x -> [x]
| BoolLit x -> [x]) : a list)
type _ t =
| IntLit : int -> int list t
| BoolLit : bool -> bool list t
let eval : type a . a list t -> (a * a) list =
fun term ->
List.map (fun x -> x, x)
((match term with
| IntLit x -> [x]
| BoolLit x -> [x]) : a list)
type foo_builder = {
mutable foo_b : int option;
mutable bar_b : float option;
mutable baz_b : string option;
}
type foo = {
foo : int;
bar : float;
baz : string;
module type CON = sig
type 'a t
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
end
(* (stdlib) List doesn't include 'a t, add it *)
module ListT = struct
type 'a t = 'a list
include List
end
(global-set-key (kbd "<f5>") 'compile)
(define-minor-mode test-mode "test mode" nil "TEST"
'(([remap compile] . new-compile)))
(defun new-compile ()
(interactive)
(message "shiny"))
(global-set-key (kbd "C-x c") 'compile)
(define-minor-mode ludus-mode "A minor mode for developing the ludus project" nil "Ludus"
'(([rebind compile] . ludus-compile)))
(defun ludus-compile ()
(interactive)
(insert "ding"))
(define-minor-mode test-mode "test mode" nil "TEST"