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 Generic = struct | |
(* generic expr type used for matching *) | |
type expr = | |
| A | |
| B of expr * expr [@lang a] | |
| C of expr [@lang b c] | |
| Unsupported of string [@fallback] | |
end | |
(*** Generated from the above ***) |
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 kind = [ | |
| Root (* class name conflict *) | |
| Thing of int | |
| WOW <json name="wow"> | |
| Amaze <json name="!!!"> of string list | |
] | |
type root = { | |
id: string; | |
await: bool; |
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
from typing import List | |
import json | |
# type t = A | B of int | |
class T: | |
pass | |
class T_A(T): | |
def __repr__(self): |
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
(* Arithmetic with Binary numbers (unsigned, arbitrary precision!) *) | |
type digit = Zero | One | |
type t = digit list | |
let rec eq a b = | |
match a, b with | |
| [], [] -> true | |
| da :: a, db :: b when da = db -> eq a b | |
| _ -> false |
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
(* | |
Evaluate the performance of a stack-safe implementation of List.map. | |
Run with: | |
ocamlopt -o list_map unix.cmxa list_map.ml | |
./list_map | |
*) | |
open Printf |
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
(* | |
Extra string operations for OCaml | |
Conventions: | |
- all operations are failsafe: no exceptions are raised | |
- negative index i is equivalent to positive index (length - i) | |
- from/until indicate inclusive ranges like in 'for' loops | |
(for i = from to until do ... done) | |
- does not replicate or override the standard String module |
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
#! /usr/bin/env bash | |
# | |
# Remove a single git commit from history. | |
# | |
set -eu | |
usage() { | |
cat <<EOF | |
Usage: $0 <commit ID> |
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
(* Generated by ocaml-tree-sitter. *) | |
(* | |
typescript grammar | |
entrypoint: program | |
*) | |
open! Sexplib.Conv | |
open Tree_sitter_run |
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
(** | |
Boilerplate to be used as a template when mapping the java CST | |
to another type of tree. | |
*) | |
(* Disable warnings against unused variables *) | |
[@@@warning "-26-27"] | |
(* Disable warning against unused 'rec' *) | |
[@@@warning "-39"] |
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
(** | |
Boilerplate to be used as a template when mapping the java CST | |
to another type of tree. | |
*) | |
(* Disable warnings against unused variables *) | |
[@@@warning "-26-27"] | |
(* Disable warning against unused 'rec' *) | |
[@@@warning "-39"] |
NewerOlder