Skip to content

Instantly share code, notes, and snippets.

View bsansouci's full-sized avatar

Benjamin San Souci bsansouci

View GitHub Profile
let layoutViews = () => {
let t = Js.Date.now()
// Initialize the views and get the tallest narrative headline
// @Todo this could just go over narratives instead of all snips...
let tallestNarrativeHeadline = ref(0.)
let m: ref<Belt.Map.Int.t<timelineElementViewT>> = ref(Belt.Map.Int.empty)
for i in 0 to state.narrativeHeadlineViews->Array.length - 1 {
@bsansouci
bsansouci / firebase.res
Created January 5, 2021 18:45
Firebase bindings for ReScript with new import syntax
@bs.val external prod: bool = "process.env.PROD"
// Effectful imports
%raw("require('firebase/auth')")
%raw("require('firebase/functions')")
%raw("require('firebase/firestore')")
type userT = {
displayName: string,
email: string,
let bodyView = document.body;
bodyView.style.position = "absolute";
let rect = bodyView.getBoundingClientRect();
bodyView.style.width = "100%";
bodyView.style.height = "100%";
let body = {
pos: {
x: 40,
{"lastUpload":"2020-01-15T07:27:39.390Z","extensionVersion":"v3.4.3"}
// Bug 1
// Typescript only looks at the fields and methods to type check, not the constructors.
// Root cause: structural typing
class Animal {
feet: number;
constructor(name: string, numFeet: number) { }
}
class Size {
feet: number;
@bsansouci
bsansouci / env.sh
Created December 16, 2017 07:38
`esy b env`
cur__root=/Users/benjamin/Desktop/tmp/example2
esy_build__build_type=out-of-source
cur__toplevel=/Users/benjamin/Desktop/tmp/example2/node_modules/.cache/_esy/store/s/bsb_native_example-0.0.0-5f5bb9b0/toplevel
SHELL=env -i /bin/bash --norc --noprofile
cur__target_dir=/Users/benjamin/Desktop/tmp/example2/node_modules/.cache/_esy/store/b/bsb_native_example-0.0.0-5f5bb9b0
esy_build__source_root=/Users/benjamin/Desktop/tmp/example2
cur__depends=
esy_build__source_type=root
esy_build__install_command=
OCAMLPATH=
value _11_SDL_SetHint(value x36, value x35)
{
char* x37 = CTYPES_ADDR_OF_FATPTR(x36);
char* x38 = CTYPES_ADDR_OF_FATPTR(x35);
int x39 = SDL_SetHint(x37, x38);
return Val_long(x39);
}
/* Template for proposals to update the syntax.
This lists all cases of function definition, function type definition and function application.
Full credit to Jordan Walke, I copied the list from https://gist.github.com/jordwalke/6935739b74eb9b8496670cc7860f5acf and
only minorly tweaked it. */
let a = 10;
let b = 20;
/* A */
let nonNamed a b => a + b;
/* The only whitespace sensitivity here is between the first colon and the named argument
let a c :b => c
VS
let a c : b => c
The former is a function that takes 2 arguments where the 2nd one is a named argument, and it returns `c` of open type.
The latter one is a function that takes one argument and that returns `c` of type `b`
*/
let a = 10;
let b = 20;