This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PrimitiveData = string | number | boolean | null | |
type ListData = LensData[] | |
type ObjectData = { | |
[key: string]: LensData | |
} | |
type LensData = PrimitiveData | ListData | ObjectData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pipe<A, B>(a: A, f: (a: A) => B): B; | |
function pipe<A, B, C>(a: A, f: (a: A) => B, g: (b: B) => C): C; | |
function pipe<A, B, C, D>( | |
a: A, | |
f: (a: A) => B, | |
g: (b: B) => C, | |
h: (c: C) => D | |
): D; | |
function pipe<A, B, C, D, E>( | |
a: A, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pipe<A, B>(a: A, f: (a: A) => B): B; | |
function pipe<A, B, C>(a: A, f: (a: A) => B, g: (b: B) => C): C; | |
function pipe<A, B, C, D>( | |
a: A, | |
f: (a: A) => B, | |
g: (b: B) => C, | |
h: (c: C) => D | |
): D; | |
function pipe<A, B, C, D, E>( | |
a: A, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
extern crate peg; | |
#[derive(Debug, Clone, PartialEq, Eq, Hash)] | |
struct Variable(String); | |
#[derive(Debug, Clone, PartialEq, Eq, Hash)] | |
enum Value { | |
Integer(i32), | |
Variable(Variable), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// library | |
type Handler<T, R> = [new (...args: any) => T, (input: T) => R]; | |
type HandlerPattern<T extends Handler<any, any>> = T extends Handler< | |
infer Pattern, | |
any | |
> | |
? Pattern | |
: unknown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Prettier<T> = { | |
[key in keyof T]: T[key]; | |
} | |
type Tagged<Tag extends string> = { | |
tag: Tag; | |
}; | |
type Field<Key extends string, Value> = { | |
[key in Key]: Value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
domain TodoInputDomain { | |
state TodoInput = '' | |
command updateTodoInput(newTodoInput: string) { | |
return TodoInput.new(newTodoInput) | |
} | |
} | |
type Todo = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// type utils | |
type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends ( | |
x: infer R | |
) => any | |
? R | |
: never; | |
type UnionOf<T extends object> = T[keyof T]; | |
type IntersectionOf<T extends object> = UnionToIntersection<UnionOf<T>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ProcedureContext = { | |
path: Procedure[]; | |
next: (procedure: Procedure) => void; | |
}; | |
type Procedure = { | |
run: (ctx: ProcedureContext) => unknown; | |
}; | |
const runProcedure = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Fetch<K = unknown, V = unknown> = (key: K) => V | |
type Task<K = unknown, V = unknown> = (fetch: Fetch<K, V>) => V | |
type Tasks<K = unknown, V = unknown> = (key: K) => Task<K, V> | null | |
type Store<K, V> = Map<K, V> | |
type Build<K, V> = (tasks: Tasks<K, V>, key: K, store: Store<K, V>) => void |
NewerOlder