- Package vendoring with OPAM
- Dual numbers / Automatic differentiation
- Sumbolic differentiation
- Pure-functional precedence parsing
- fold_left as recursion scheme
open Printf | |
module type GENERIC = sig | |
type t | |
val constructor : string -> int -> t list -> t | |
val string : string -> t | |
val int : int -> t | |
end |
#! /usr/bin/env ocaml | |
type some_interface = < | |
foo : unit -> unit | |
> | |
let do_stuff (p : some_interface) = | |
p#foo () |
#! /usr/bin/env ocaml | |
(* From http://keleshev.com/point-free-case-analysis *) | |
open Printf | |
let id x = x | |
let const x _ = x | |
(* |
(* https://www.infoq.com/presentations/Thinking-Parallel-Programming *) | |
open Printf | |
let (=>) left right = printf "%c" (if left = right then '.' else 'F') | |
let print_list list = printf "[%s]" (String.concat "; " list) | |
let sprint_list list = sprintf "[%s]" (String.concat "; " list) | |
module Cat = struct |
open Printf | |
let (=>) left right = printf "%c" (if left = right then '.' else 'F') | |
module CharString = struct | |
type t = Empty | Char of char * t | |
let rec fold ~empty ~char = function | |
| Empty -> empty |
(* type 'a succ *) | |
module Slit = struct | |
type zero | |
type 'a succ = X | |
type (_, _) t = |
open Printf | |
let (=>) left right = printf "%c" (if left = right then '.' else 'F') | |
let print_list list = printf "[%s]" (String.concat "; " list) | |
let sprint_list list = sprintf "[%s]" (String.concat "; " list) | |
(* From blog post Interpretations of Fold, | |
https://keleshev.com/interpretations-of-fold *) | |
let (=>) left right = print_char (if left = right then '.' else 'F') | |
open Printf | |
let id x = x | |
let const x = fun _ -> x | |
let sum = List.fold_left (+) 0 | |
let (>>) f g x = g (f x) |
open Printf | |
module Syntax = struct | |
type t = | |
| Unit | |
| Boolean of bool | |
| Number of int | |
| Name of string | |
| Divide of t * t |