Skip to content

Instantly share code, notes, and snippets.

@xaviervia
Created March 16, 2017 22:11
Show Gist options
  • Save xaviervia/84d8ac801d5e588915a8099398b75bfd to your computer and use it in GitHub Desktop.
Save xaviervia/84d8ac801d5e588915a8099398b75bfd to your computer and use it in GitHub Desktop.
const three = {
type: () => [Integer],
value: 3
}
const three = {
type: () => [Integer],
value: 3
}
const sum = {
type: () => [Arrow, [Tuple, Integer, Integer], Integer],
value: (x, y) => x + y
}
const threeAndFour = {
type: () => [Tuple, Integer, Integer],
value: [three, four]
}
eq(
sum.ap(threeAndFour),
{
type: () => [Integer],
value: 7
}
)
const Arrow = {
type: (a, b) => [Type, a, b],
value: {
ap: {
type: a => [Arrow, a, a],
value: self => argument => self(argument)
},
pipe: {
type: (a, b) => [Arrow, a, b]
value: self => argument => other => self(argument(other))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment