Skip to content

Instantly share code, notes, and snippets.

@beattyml1
Created March 1, 2019 20:09
Show Gist options
  • Save beattyml1/550f338b4da6e892ab27a0cfc16a2f25 to your computer and use it in GitHub Desktop.
Save beattyml1/550f338b4da6e892ab27a0cfc16a2f25 to your computer and use it in GitHub Desktop.
ts operators
import {and as bool_and} from 'boolean'
import {and as num_and} from 'number'
@operator
export const and = overload(bool_and, num_and)
@operator
@overload((a, b) => typeof a === 'boolean' && typeof b === 'boolean'))
export function and (a: boolean, b: boolean) {
return a && b;
}
@operator('|>', '.')
export function pipe<X>(val: X, func: (x: X) => Y): Y {
return func(value)
}
import { and, pipe } from './operators'
let f = (f1, f2) => (a, b) => (a |> f1 |> f2) and (b |> f1 |> f2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment