This file contains hidden or 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 yoneda = f => cont => a => cont(f(a)) | |
const cpsTransform = yoneda | |
const f = x => x + 1 | |
const g = x => x * 2 | |
const apply = (g, f) => x => g(f(x)) | |
/* | |
apply(cpsTransform(f), cpsTransform(g))(cont) |
This file contains hidden or 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
(* http://m-hiyama.hatenablog.com/entry/20080116/1200468797 *) | |
Module cps. | |
(* CPS transformation *) | |
Definition yoneda (X Y A: Type) (f: X -> Y) : (Y -> A) -> X -> A := | |
fun cont: Y -> A => fun x: X => cont (f x). | |
Definition yoneda_objpart (X A: Type) (x: X) : (X -> A) -> A := | |
fun cont: X -> A => cont(x). |
OlderNewer