Instantly share code, notes, and snippets.

View type-list.js
// @flow
// Type-level lists
type Empty = []
// Type-level tail function
type Tail<L> = $Call<FTail, L>
interface FTail {
(Empty): Empty,
<H, T>([H, T]): T
View type-nat.js
// @flow
// Type-level naturals
type Zero = 0
interface Succ {
<N>(N): [1, N]
}
// Hey look, we can do type-level pattern matching
View lazy-pair.js
// Pair helpers
// Map the first element of a pair
const first = <A, B, C> (f: A => B, [a, c]: [A, C]): [B, C] =>
[f(a), c]
// Map the second element of a pair
const second = <A, B, C> (f: B => C, [a, b]: [A, B]): [A, C] =>
[a, f(b)]
View except.js
// @flow
import { curry2, curry3 } from '@most/prelude'
export type Except<E, A> = Exception<E, A> | Result<E, A>
export const result = <E, A> (a: A): Except<E, A> =>
new Result(a)
export const throwError = <E, A> (e: E): Except<E, A> =>
new Exception(e)
View 433.js
import { tap, take, skip, concat, fromArray, runEffects } from '../packages/core/src/index'
import { newDefaultScheduler } from '../packages/scheduler/src/index'
import { EventEmitter } from 'events'
import multicastStream from '@most/multicast'
import { fromEvent } from 'most'
const emitter = new EventEmitter()
const scheduler = newDefaultScheduler()
const observe = (f, stream) => runEffects(tap(f, stream), scheduler)