Created
January 3, 2017 15:41
-
-
Save davidchase/1529f90ea8dee952d748dda1596f7b21 to your computer and use it in GitHub Desktop.
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
const Coyo = (f, v) => ({fn: f, val: v}) | |
const id = x => x | |
const liftCoyo = a => Coyo(id, a) | |
const fmap = (fn, coyo) => Coyo(compose(fn, coyo.fn), coyo.val) | |
const lower = coyo => map(coyo.fn, coyo.val) | |
const bindCoyo = (fn, coyo) => liftCoyo(chain(compose(lower, coyo.fn, fn), coyo.val)) | |
const apCoyo = (f, g) => liftCoyo(ap(lower(f), lower(g))) | |
apCoyo(liftCoyo([inc, add(10)]), liftCoyo([1,2,3])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment