Skip to content

Instantly share code, notes, and snippets.

@skatenerd
Created August 23, 2016 14:38
Show Gist options
  • Save skatenerd/6fc88253708c36f01e9a1919384bb3db to your computer and use it in GitHub Desktop.
Save skatenerd/6fc88253708c36f01e9a1919384bb3db to your computer and use it in GitHub Desktop.
pipeline vs composition
-- pipelining
let x = 1
doubled = x * 2
squared = doubled * doubled
decremented = squared - 1
in decremented
-- composition
let x = 1
double = (*) 2
square x = x * x
decrement x = x - 1
in (decrement . square . double) x
@skatenerd
Copy link
Author

@raganwald, Thanks for responding!

I'm not sure I understand the distinction. In this case, both let statements could just be the body of a first-class function, which could be named, passed around, composed, etc.

Maybe this example is just too small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment