Skip to content

Instantly share code, notes, and snippets.

@siassaj
Created December 11, 2018 13:53
Show Gist options
  • Select an option

  • Save siassaj/d4be57f33784a06365da8b6047c413de to your computer and use it in GitHub Desktop.

Select an option

Save siassaj/d4be57f33784a06365da8b6047c413de to your computer and use it in GitHub Desktop.
type Dict<T> = { [key: string]: T }
interface component {
bacon: Stream<string>
lettuce?: Stream<number>
}
type baconArgs = {
firstBastard: Stream<string>,
secondBastard: Stream<string>
}
function bacon(args: baconArgs): Stream<string> {
return xs.merge(args.firstBastard, args.secondBastard)
}
type lettuceArgs = {
secondBastard: Stream<number>
}
function lettuce(args: lettuceArgs): Stream<number> {
return xs.merge(args.secondBastard)
}
function mix <
T extends Dict<component>,
V extends component,
U extends { [K in keyof component]: (a: {[key in keyof T]: T[key][K]}) => component[K] }
>(components: T, combinators: U): void {
}
mix({
firstBastard: {
bacon: xs.of('abc')
},
secondBastard: {
bacon: xs.of('abcde'),
lettuce: xs.of(123)
}
}, {
bacon: bacon,
lettuce: lettuce
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment