Skip to content

Instantly share code, notes, and snippets.

/*
module Gettable = {
type empty;
type index('full, 'nth) =
| Zero: index('nth => 'more, 'nth)
| Succ(index('full, 'nth)): index('more => 'full, 'nth);
type t('ty) =
module type Component = {
type slots;
type nextSlots;
type render;
let handedOffInstance:
ref(
option(
instance(slots, nextSlots, syntheticElement, outputNodeGroup),
),
@wokalski
wokalski / build.log
Created July 30, 2018 08:39
esy ocaml 4.07.0 build
This file has been truncated, but you can view the full file.
info esy build 0.2.3
info found esy manifests: esy.json
info Building [email protected]: starting
info Building [email protected]: starting
info Building [email protected]: starting
info Building @esy-ocaml/[email protected]: starting
info Building @esy-ocaml/[email protected]: complete
info Building @esy-ocaml/[email protected]: starting
info Building @esy-ocaml/[email protected]: complete
info Building [email protected]: complete
PX_PCT_ANIMATED_INTERPOLATED=("height" "width" "top" "bottom" "left" "right")
PX_AUTO=( ("margin" ("" "Bottom" "Top" "Right" "Left" "Horizontal" "Vertical")))
PX_PCT=( ("flexBasis" ("")) ("max" ("Height" "Width")) ("min" ("Width" "Height")) ("padding" ("" "Horizontal" "Vertical" "Left" "Right" "Bottom" "Top")))
REPLACE=(
("transform" "Transform.make")
("transformAnimated" "Transform.makeAnimated")
("transformInterpolated" "Transform.makeInterpolated")
("\`flexStart" "FlexStart")
("\`flexEnd" "FlexEnd")
("\`center" "Center")
@wokalski
wokalski / state-tree-navigation.md
Last active October 13, 2017 09:18
Simple state management for navigation

Assumption:

We want a statically typed scene hierarchy in such a way that when we move between nested screens, we pass state/props down and it can be updated. The state should live as close to the subtree as possible.

In other words, the view tree in a navigator looks like this:

       Navigator
    /     |     \
Scene1  Scene2  Scene3
@wokalski
wokalski / Reoder_graphql.re
Last active September 21, 2017 16:09
A reordering algorithm
let stringByMovingChar c x => Char.(escaped (chr @@ code c + x));
let trimFirst x => String.sub x 1 (String.length x - 1);
let rec orderAfter x =>
switch x {
| "" => "1"
| _ =>
switch x.[0] {
| '9' => "9" ^ orderAfter (trimFirst x)
| c => stringByMovingChar c 1
}
@wokalski
wokalski / Inference_problem.swift
Created August 19, 2017 20:14
Swift version 4.0 (swiftlang-900.0.59 clang-900.0.34.2)
fileprivate func splitOnTheMiddle<T: RandomAccessCollection>(inItems items: T)
-> Optional<(head: T.SubSequence, item: T.Element, tail: T.SubSequence)> where T.IndexDistance == Int, T.Index == Int, T.SubSequence: RandomAccessCollection {
if items.count == 0 {
return .none
}
let lastIndex = items.count - 1
let middleIndex = lastIndex / 2
let head = items.dropLast(lastIndex - middleIndex + 1)
let tail = items.dropFirst(middleIndex + 1)
return (head: head, item: items[middleIndex], tail: tail)
@wokalski
wokalski / file.re
Last active May 9, 2017 17:31
Very sad OCaml module situation
/* Problem1 */
module Y = {
/* Why is this include needed? */
include File2.Common;
type item = {x: string};
let renderItem x => x.item.x;
};
module MyList = File2.CreateComponent2 Y;
external view : ReactRe.reactClass = "SectionList" [@@bs.module "react-native"];
module Common = {
type section 'a = {data: array 'a, key: option string};
type renderBag 'a = {
item: 'a,
index: int,
section: section 'a,
separators: Js.t {. highlight : unit => unit, unhighlight : unit => unit}
};
@wokalski
wokalski / How to.md
Last active May 6, 2017 16:45
Minimal setup for react-native with reason

With the config above Bucklescript will look for your Reason code in ./ml directory of your project. Keep in mind that it's not recursive so it won't include subdirectories.

It assumes that you have npm or yarn installed.

After creating a directory and adding bsconfig.json and package.json run yarn/npm install.

The guide on setting up the environment is [here](https://facebook.github.io/reason/tools.html].