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
#! /usr/bin/env ocaml | |
let fprintf = Format.fprintf | |
type t = | |
| Tag of {name: string; attributes: (string * string) list; body: t list} | |
| String of string | |
let format_attribute f (key, value) = fprintf f " %s=\"%s\"" key value |
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 Id = struct | |
let (>>=) value callback = | |
callback value | |
let return x = x | |
let get x = x | |
end |
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
(* Paper: https://pdfs.semanticscholar.org/6485/84a9a714adc95a103c26d18b54c4aad1c812.pdf *) | |
module type EFFECT = sig | |
type 'unimo t | |
end | |
module Unimo (Effect : EFFECT) = struct |
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
open Printf | |
module Number = struct | |
type t = [ `Num of int ] | |
let eval (`Num n) = n | |
let to_string (`Num n) = string_of_int n | |
end |
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 MONAD = sig | |
type 'a t | |
val return : 'a -> 'a t | |
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t | |
end | |
module type MONAD2 = sig |
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 fix f_nonrec = | |
let rec f t = f_nonrec f t in | |
f | |
module Syntax = struct | |
module Open = struct | |
type 'r t = [ | |
| `Unit | |
| `Boolean of bool |
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 MONAD = sig | |
type 'a t | |
val return : 'a -> 'a t | |
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t | |
end | |
module Option : (MONAD with type 'a t = 'a option) = struct | |
type 'a t = 'a option |
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
(* | |
* This file can be executed by running: | |
* $ ocaml -rectypes map-as-a-recursion-scheme.ml | |
* | |
*) | |
open Printf | |
(* |
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 (=>) left right = print_char (if left = right then '.' else 'F') | |
module Site = struct | |
type t = int | |
let max_filenames = 400 |
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 INLINE_SUM = functor | |
(Immediate: sig type t end) (Reference: sig type t end) -> | |
sig | |
type t |