Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Practically Functional Programming

Alex Reichert edited this page Jul 31, 2016 · 1 revision

What is functional programming?

  • Functions map input to output
  • Given the same input, we always get the same output ("pure" functions, no side effects)
  • Passing one function's output to another function's input ("composition")
    • Write little functions
    • Compose them
    • f(g(x))
  • Break problems down into easy testable subproblems

What is composition?

  • We can compose functions, behaviors, data structures, architecture, etc.
  • Solves issues with state and data flow

Category Theory (worth looking into)

  • Object -> String -> Int -> Bool (all the functions in our program)
  • Object -> Bool (this is the entire program)

Functor

  • A type with a map method that preserves composition

Monad

  • A monad is a functor
  • A type with a chain method that preserves composition
Clone this wiki locally