Skip to content

Instantly share code, notes, and snippets.

View agalatan's full-sized avatar

Alin Galatan agalatan

View GitHub Profile
@agalatan
agalatan / hom-1.js
Last active November 13, 2021 04:04
The HOM functor for the Flow type category
//@flow
import * as React from 'react';
type Hom<-A, +B> = React.AbstractComponent<A, B>;
// A is the Category of Props: They are represented as objects { [string]: any }
// B is the Category of Elements: They are represented as JSX.
//
// Diverging now into other another Category: the category of Sets
// Fix for now a map
@agalatan
agalatan / Conditionals.js
Last active June 29, 2022 22:08
[Flow] Conditional types
// See the flow link at the bottom, and the GIT comment below
// Good utils
type $If<X: boolean, Then, Else = empty> = $Call<((true, Then, Else) => Then) & ((false, Then, Else) => Else), X, Then, Else>;
type $Not<X: boolean> = $If<X, false, true>;
type $And<X: boolean, Y: boolean> = $If<X, Y, false>;
type $Or<X: boolean, Y: boolean> = $If<X, true, Y>;
// Unique, internal Symbols. Probably I can actually use JS's Symbol. Need to see how well Flow implements it