Skip to content

Instantly share code, notes, and snippets.

@hcarty
hcarty / merlin.log
Created July 26, 2017 16:45
merlin debug log
# 0.50 Mconfig - normalize
{
"ocaml": {
"include_dirs": [],
"no_std_include": false,
"unsafe": false,
"classic": false,
"principal": false,
"real_paths": false,
@hcarty
hcarty / refmt.md
Created October 3, 2017 19:05
refmt >>= examples

Using 1.13.7

$ echo 'x >>= fun y -> y >>= fun z -> a' | refmt --parse=ml --print=re -w 10
x
>>= (
  fun
  y =>
    y
 >>= (
@hcarty
hcarty / Makefile
Last active October 19, 2017 17:33
Makefile template for a jbuilder-backed OCaml/Reason library project
.PHONY: all test benchmark doc repl clean gh-pages
all:
jbuilder build --dev
test:
jbuilder runtest --dev
benchmark:
jbuilder build benchmark/bench.exe
@hcarty
hcarty / tar_gz_example.ml
Last active September 14, 2018 14:19
Simple .tar.gz blob of bytes extractor using ezgzip + ocaml-tar
(* This requires ezgzip and tar, probably installed via opam. The simplest way to test this code is:
$ utop tar_gz_example.ml
with a test.tar.gz file existing in the current directory. If test.tar.gz contains a lot of data
then your computer may have a bad time as this extracts everything from the tar file into
memory. *)
#require "ezgzip";;
#require "tar";;
(* Convenience - used for sanity checks to make sure the tar content
@hcarty
hcarty / server.ml
Created January 16, 2019 04:22
Simple WIP http/af server
let make_headers content_length =
Httpaf.Headers.of_list
[("content-length", string_of_int content_length); ("connection", "close")]
let request_handler _client_address (reqd : Lwt_unix.file_descr Httpaf.Reqd.t)
=
let request = Httpaf.Reqd.request reqd in
let uri = Uri.of_string request.target in
let meth = request.meth in
match (meth, Uri.path uri) with
@hcarty
hcarty / package.json
Created April 25, 2019 02:52
WIP Windows-specific pkg-config build for esy
{
"name": "yarn-pkg-config",
"source": "archive:https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz#76e501663b29cb7580245720edfb6106164fad2b",
"override": {
"buildsInSource": true,
"build": [
[
"find",
"./",
"-exec",
@hcarty
hcarty / esy.json-fragment
Created April 30, 2019 16:29
esy resolution for GMP
"gmp": {
"source": "archive:https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz#9dc6981197a7d92f339192eea974f5eca48fcffe",
"override": {
"buildsInSource": true,
"build": [
"find ./ -exec touch -t 200905010101 {} +",
"./configure --prefix=#{self.install} --host x86_64-w64-mingw32 CFLAGS=-fPIC",
"make"
],
"install": [
@hcarty
hcarty / backtrace.txt
Created June 21, 2019 15:00
esy error
$ esy
info esy 0.6.0 (using esy.json)
info checking https://github.com/ocaml/opam-repository for updates...
info checking https://github.com/esy-ocaml/esy-opam-override for updates...
info resolving esy packages: done
esy: internal error, uncaught exception:
(Failure
"inconsistent state: found a package not in the cudf version map @opam/mysql@link:../upstream/ocaml-mysql")
Raised at file "pervasives.ml", line 32, characters 17-33
Called from file "esy-solve/Universe.re", line 638, characters 22-189
@hcarty
hcarty / pipeline_gadt_experiment.ml
Created August 5, 2019 19:18
GADT to wrap steps when using lwt_pipeline
type ('a, 'b) pipeline =
| [] : ('a, 'a) pipeline
| ( :: ) : ('a, 'b) Pipeline.step * ('b, 'c) pipeline -> ('a, 'c) pipeline
let pointless_pipeline = [Pipeline.sync sin; Pipeline.sync cos; Pipeline.sync Float.to_string]
@hcarty
hcarty / .ocamlformat
Last active December 5, 2019 23:44
Experimenting with ocamlformat settings
version = 0.12
profile = default
break-cases = toplevel
break-fun-decl = fit-or-vertical
break-infix = fit-or-vertical
cases-exp-indent = 2
doc-comments-padding = 1
if-then-else = k-r
indicate-multiline-delimiters = closing-on-separate-line
leading-nested-match-parens = true