Your SlideShare is downloading. ×
0
3 FP Concepts                Recursion, List comprehensions and Monads@diego_pacheco  about.me/diegopacheco
3 FP Concepts  Recursion  List Comprehensions  Monads
Recursion
Recursion Function defined inside a function Function calling it-self Defining an infinite set of objects by a finitest...
Recursion
List Comprehensions
List Comprehensions Syntactic construct based on lists Inspired by math: set comprehensions Expressions on lists, power...
List Comprehensions
Monads
Monads => NO State on a world FULL ofState, Looks nonsense!? WTF?
FP/Haskell are against state? Hell No!It’s all about discipline state…
How to Deal with state without globalshared state variables ?
Workaround => Truck Food as Monad !!!  (Abstraction)
Monads Deal with side-effects in a functional way Mathematical construct Without monads PURE FP would be nuts Function...
Monads as types/class (>>=), OOP!?
Monads have laws…                        its not just type/classes                        Make possible assumptions about ...
Monads         >>= (bind)
Monads
https://github.com/diegopacheco/functional-society
3 FP Concepts                   Thank You!                    Obrigado!                Higher Order Functions, Lambda and ...
Upcoming SlideShare
Loading in...5
×

3 FP Concepts: Recursion, List Comprehensions and Monads

4,021

Published on

3 FP Concepts: Recursion, List Comprehensions and Monads

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,021
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
25
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "3 FP Concepts: Recursion, List Comprehensions and Monads"

  1. 1. 3 FP Concepts Recursion, List comprehensions and Monads@diego_pacheco  about.me/diegopacheco
  2. 2. 3 FP Concepts Recursion List Comprehensions Monads
  3. 3. Recursion
  4. 4. Recursion Function defined inside a function Function calling it-self Defining an infinite set of objects by a finitestatement (Recursion Power by Wikipedia) Same behavior as loop, for, while, etc…
  5. 5. Recursion
  6. 6. List Comprehensions
  7. 7. List Comprehensions Syntactic construct based on lists Inspired by math: set comprehensions Expressions on lists, powerful stuff!
  8. 8. List Comprehensions
  9. 9. Monads
  10. 10. Monads => NO State on a world FULL ofState, Looks nonsense!? WTF?
  11. 11. FP/Haskell are against state? Hell No!It’s all about discipline state…
  12. 12. How to Deal with state without globalshared state variables ?
  13. 13. Workaround => Truck Food as Monad !!! (Abstraction)
  14. 14. Monads Deal with side-effects in a functional way Mathematical construct Without monads PURE FP would be nuts Functional able todo IO Good to Control tracking of things Similar to AOP Interceptors Function Composition: LINQ, Unix Pipes You can build environments that support exactlythe features that you want (Scala Option[A]) Encapsulating two things:  control flow (Maybe, Error, List, Continuation, parser monads)  state propagation (State, Reader, Writer, IO)
  15. 15. Monads as types/class (>>=), OOP!?
  16. 16. Monads have laws… its not just type/classes Make possible assumptions about the type/class and his behavior.1. Left Identity (apply function to value) return x >>= f (the same as) f x sample: return 3 >>= (x -> Just (x+100000))2. Right Identity (value to feed return) m >>= return (the same as) m sample: [1,2,3,4] >>= (x -> return x)3. Associativity (no matter how nested chain) (m >>= f) >>= g (the same as) m >>= (x -> f x >>= g) sample: return (0,0) >>= landRight 2 >>= landLeft 2 >>= landRight 2
  17. 17. Monads >>= (bind)
  18. 18. Monads
  19. 19. https://github.com/diegopacheco/functional-society
  20. 20. 3 FP Concepts Thank You! Obrigado! Higher Order Functions, Lambda and Currying@diego_pacheco  about.me/diegopacheco
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×