Skip to content

Instantly share code, notes, and snippets.

@jordwalke
jordwalke / package.json
Created March 4, 2020 01:17
package.json that reproduces sdl2 failure.
{
"name": "myproject",
"version": "0.0.1",
"description": "myproject",
"license": "PRIVATE",
"esy": {
"build": "refmterr dune build -p AppExe",
"buildsInSource": "_build",
"buildEnv": {
"ODOC_SYNTAX": "re"
error: build failed with exit code: 1
build log:
# esy-build-package: building: reason-sdl2@2.10.3018
# esy-build-package: pwd: /Users/jwalke/.esy/source/i/reason_sdl2__2.10.3018__dacc7a39
# esy-build-package: running: 'dune' 'build' '-p' 'sdl2'
gcc src/sdl2_wrapper.o (exit 1)
(cd /Users/jwalke/.esy/3/b/reason_sdl2-2.10.3018-5aa8652b/default/src && /usr/bin/gcc -I /Users/jwalke/.esy/3__________________________________________________________________/i/ocaml-4.9.0-27f2b357/lib/ocaml -I /Users/jwalke/.esy/3__________________________________________________________________/i/esy_sdl2-2.0.10005-690e644d/include -I /Users/jwalke/.esy/source/i/reason_sdl2__2.10.3018__dacc7a39/include -I /Users/jwalke/.esy/source/i/reason_sdl2__2.10.3018__dacc7a39/src -x objective-c++ -g -o sdl2_wrapper.o -c sdl2_wrapper.cpp)
sdl2_wrapper.cpp:1241:24: error: assigning to 'value *' (aka 'long *') from incompatible type 'const value *' (aka 'const long *')
reason_sdl_onLog = caml_named_value(
@jordwalke
jordwalke / tutorial.md
Created October 2, 2019 20:54
Adding A ReHP backend quick tutorial.

Getting started with adding a backend for Rehp for a new language.

Let me know where you hit friction with these instructions and I'll clarify.

  • Clone rehp
  • grep -r php . to see various references to PHP. That shows you what was done to extend the compiler to add a new backend. You will be doing something very similar. In general, the best way to get started is to copy/paste everything that was done for PHP, to add your new backend.
  • Check out the file compiler/lib/rehp.re This is the new intermediate representation that was added to the jsoo compiler. Rehp uses the bytecode disassembler from jsoo, and instead of turning it into js, it turns it into this other intermediate representation called "Rehp"- which is defined bycompiler/lib/rehp.re`.
  • Add your backend to compiler/lib/backend.ml/i including info about the file extension.
  • Add a new file compiler/lib/YourLang.re, which can start out as a copy of the compiler/lib/php.re file. This represents the
@jordwalke
jordwalke / watch.sh
Last active September 19, 2018 22:30
Watcher Script Using Unix Find.
#!/bin/bash
# Invoke like this:
# ./watch.sh my command here
# And it will run 'my command here' once, and then when it detects changes.
# TODO: Don't just search in the last second. Search for updates since the last
# completed build. Otherwise for big directories, midway through your search
# you've already taken 1s and you will miss updates.
@jordwalke
jordwalke / fnd.sh
Created November 8, 2017 01:56
Better find.
# https://stackoverflow.com/a/28938235
fnd () {
UNDER_ON=`tput smul`
UNDER_OFF=`tput rmul`
BOLD=`tput bold` # Select bold mode
BLACK=`tput setaf 0`
RED=`tput setaf 1`
GREEN=`tput setaf 2`
YELLOW=`tput setaf 3`
BLUE=`tput setaf 4`
@jordwalke
jordwalke / routes.re
Created October 17, 2017 03:25
Routes.re
module type RouteParams = {type t; let makeParams: unit => t;};
module type RouteIntf = {type t; type params; let getParams: t => params;};
module MakeRoute (Params: RouteParams) :RouteIntf => {
type t = {path: string};
type params = Params.t;
let getParams _ => Params.makeParams ();
};
@jordwalke
jordwalke / stringKeys.js
Created April 17, 2016 09:19
bucklescript output using conventional JS keys.
// Generated CODE, PLEASE EDIT WITH CARE
'use strict';
var invalid_argument = /* tuple */[
248,
"Invalid_argument",
-3
];
var not_found = /* tuple */[
@jordwalke
jordwalke / existentialTypes.ml
Created August 12, 2015 06:41
Existential Types Recovering
type printable = Printable : 'a * ('a-> string) -> printable;;
let myList = [Printable (2, string_of_int); Printable (true, string_of_bool)];;
let printPrintable: printable -> string = fun p ->
let Printable (data, printer) = p in
printer data
;;
let printables = [Printable (2, string_of_int); Printable (true, string_of_bool)];;
let results = List.map printPrintable printables;;
@jordwalke
jordwalke / setupOCamlDevelopment.sh
Last active August 29, 2015 14:09
Installing OCaml and useful libraries.
# IMPORTANT: Read through this carefully to make sure you want it to do
# everything you'd like. You should actually run through this line by line
# instead of blindly running this. Specifically, you should never curl
# a script and run it without first reading it! (See the opam_installer portion)
# License: See the License at the footer of this document:
# 1. OPAM:
@jordwalke
jordwalke / gist:c60c91ff6c82d47bf605
Created August 25, 2014 07:17
Simple Module React OCaml API
(* Same example as https://gist.github.com/jordwalke/67819c91df1552009b22
but using OCaml's simple module feature (every file is a module) *)
open ReactDOM
(* Component Properties *)
type props = {count: int}
(* Hey, state can be any type! *)
type state = string