Skip to content

Instantly share code, notes, and snippets.

@objmagic
objmagic / functor_autocomplete.ml
Last active August 29, 2015 14:21
Merlin does auto complete this
(* can be compiled with $corebuild functor_autocomplete.native *)
open Core_kernel.Std
module Key : Map.Key = struct
type t = int list with sexp
let compare (l1:t) (l2:t) : int =
if Set.equal
(Set.of_list ~comparator:Int.comparator l1)
FastParser {
def rule1:Parser[(Char,Char)] = 'a' ~ 'b'
def rule2 = ('a' | 'b') ~ 'c'
def rule3 = ('a' ~ 'b') | 'c'
def rule4 = rule1 ~ (rule2 | rule3) ~ rule1
def rule5 = ('a' | 'b').rep(2,5)
}
/* --------------------------------------------------------- */
@objmagic
objmagic / .merlin
Created June 27, 2015 11:10
merlin
B _build/**
S .
EXT meta
@objmagic
objmagic / Makefile
Created June 29, 2015 15:26
unbound
#
# Build system for ocs library and interpreter
#
OCAMLBUILD = ocamlbuild
METAOCAMLC = metaocamlc
build:
$(OCAMLBUILD) -classic-display -ocamlc $(METAOCAMLC) a.byte b.byte
.<
fun state_23 ->
let res1_24 =
(fun state_13 ->
let res1_14 =
(fun state_1 ->
let ix_2 = state_1.Nparser.Char_parser.index in
let f_3 = Nparser.Char_parser.Failure state_1 in
if ix_2 < state_1.Nparser.Char_parser.length
then
type _ cgrammar =
| Lit : elem -> elem cgrammar
| Seq : 'a cgrammar * 'b cgrammar -> ('a * 'b) cgrammar
| Left : 'a cgrammar * 'b cgrammar -> 'a cgrammar
| Right : 'a cgrammar * 'b cgrammar -> 'b cgrammar
| Either : 'a cgrammar list -> 'a cgrammar
| Rep : 'a cgrammar -> ('a list) cgrammar
| Repsep : 'a cgrammar * 'b cgrammar -> ('a list) cgrammar
| TakeWhile : ('a -> bool) -> ('a list) cgrammar
| Trans : ('a -> 'b) * 'a cgrammar -> 'b cgrammar
@objmagic
objmagic / gadt-escape.ml
Last active August 29, 2015 14:24
escape
type _ grammar =
| Either : 'a grammar list -> 'a grammar
| CharLiteral : char -> char grammar
type state
type 'a result = Ok of 'a | Failure of string
type 'a parser_code = state code -> 'a result code
@objmagic
objmagic / functor.ml
Last active August 29, 2015 14:25
failed..
module type X = sig
type t
end
module type SS = sig
type t
end
module F (S: SS) : X with type t = S.t = struct
include S
@objmagic
objmagic / typeable.ml
Last active August 29, 2015 14:25
typeable.ml
module Eq = struct
type (_, _) t = Refl : ('a, 'a) t
end
type _ nttype = ..
type 'a typeable = {
constructor : 'a nttype;
eq : 'b. 'b nttype -> ('a, 'b) Eq.t option
}
@objmagic
objmagic / rec.ml
Created July 19, 2015 21:22
rec.ml
type t2 = A of t3 | C of char and t3 = t2
let rec t2_parser = NT (lazy (
either [(fun arr -> A arr) <*> arr_parser;
((fun c -> C c) <*> lit 'c')]))
and arr_parser = NT (lazy (
(lit '[') >> t2_parser << (lit ']')))