This file contains hidden or 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 _ value = | |
| Any : 'a value | |
| Float : float -> float value | |
| String : string -> string value | |
let print_string_value x = | |
match x with | |
| Any -> () |
This file contains hidden or 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 _ value = | |
| Any : 'a value | |
| String : string -> string value | |
| Float : float -> float value | |
let print_string_value : 'a . 'a value -> unit = | |
function | |
| Any -> () |
This file contains hidden or 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 = struct | |
type _ t = | |
| Bool : bool t | |
| Int : int t | |
| Float : float t | |
| Tuple : (_, 't) tuple -> 't t | |
and (_, _) tuple = | |
| Nil : ('t, 't) tuple |
This file contains hidden or 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
(* 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 -> () |
This file contains hidden or 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 = | |
| 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) |
This file contains hidden or 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 = | |
| 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) |
This file contains hidden or 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 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; |
This file contains hidden or 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 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 |
This file contains hidden or 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
(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")) |
This file contains hidden or 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
(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" |