getify / Functional-Light-JS

Pragmatic, balanced FP in JavaScript. @FLJSBook on twitter.
http://FLJSBook.com
Other
16.6k stars 1.96k forks source link

ch4 composition: add not about composition being "associative" #182

Open getify opened 5 years ago

getify commented 5 years ago
compose(compose(fn3,fn2),fn1) ~=~ compose(fn3,compose(fn2,fn1))
godhand4826 commented 5 years ago

As I know... Sets are types for programmer. If I write a function that given the same type of input(e.g. 1, 2, 3) and returns different type of output(e.g. 'a', 5, True), that will not be a set function which makes composition failed. Since composition is failed, it's no need to check if the composition being associative. If the function is just evaluate(mapping) from one type to another type(maybe the same). It will be a set function. Set functions's composition is always associative in category of set(Sets). If I'm wrong just let me know. Have a good day.