Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Epic Success V Failure ?
Refactoring to real FP
Eric Torreborre
Why, oh why?
What now?
How hard can it be?
HelloWorldSpec.scala
How hard can it be?
TextText
ExampleExample
TextText
TextText
ExampleExample
StepStep
ExampleExample
Filtering
Filtering
b...
How hard can it be?
Configuration(s)Configuration(s)ResourcesResources
FileSystemFileSystem
“Flow”“Flow”
StateState
Compos...
Problem?
Strategy
Strategy
Filtering by name
Filtering by previous
TextText ExampleExample ExampleExample TextText
StatsStats
resultresult
resultresultresultresult
res...
Monad stacks
Task[A]Task[A]
AA
ErrorError
AA
ErrorError
AA
FutureFuture
Monad stacks values
AA
ErrorError
FutureFuture
now(a: A)
delay(a: =>A)
AA
ErrorError
FutureFuture
AA
ErrorError
FutureFutu...
Action in action
Action[A]Action[A]
AA
ErrorError
AA
ErrorError
AA
IOIO
AA
ErrorError
IOIO
ReaderReader
Conf => IO[A]
=> I...
Action in action
Action opportunity
Read
everything!Read
everything!
Filtering by previous
TextText ExampleExample ExampleExample TextText
StatsStats
resultresult
resultresultresultresult
res...
Filtering by previous
TextText ExampleExample ExampleExample TextText
StatsStats
resultresult
Action[Fragment] => Task[Fra...
Filtering by previous
flatM
ap!
flatM
ap!
Filtering by previous
On stacks
No big deal
No big deal
Specialise
Specialise
LibraryLibrary
Composition?
Composition?
Integration?
Integration?
Scalaz-stream
Concurrency with
Easy!Easy!
Concurrency with
With state!
With state!
TextText ExampleExample ExampleExample StepStep ExampleExample
stop herestop here
Flatmap with
Online testing!
Online testing!
Flatmap with
Online testing!
Online testing!
Text1Text1 Example1Example1 Example2Example2 Example3Example3
Text1Text1 Exam...
Reporting with
“duplicate”
stream
“duplicate”
stream
Write to
console
Write to
console
Accumulate
state
Accumulate
state
Reporting with
Text1Text1 Example1Example1 Example2Example2 Example3Example3
“t1”“t1” “e1”“e1” “e2”“e2” “e3”“e3”
> Console...
Reporting with
Not
composable

Not
composable

Reporting with and Folds!
Reporting with and Folds!
Reporting with and Folds!
Opaque
dependent typeOpaque
dependent type
Reporting with and Folds!
Fold Monoid!
Fold Monoid!
Reporting with and Folds!
Conclusion
Upcoming SlideShare
Loading in …5
×

Epic success \/ failure, refactoring to *real* FP

My presentation at LambdaJam 2014

  • Login to see the comments

Epic success \/ failure, refactoring to *real* FP

  1. 1. Epic Success V Failure ? Refactoring to real FP Eric Torreborre
  2. 2. Why, oh why?
  3. 3. What now?
  4. 4. How hard can it be? HelloWorldSpec.scala
  5. 5. How hard can it be? TextText ExampleExample TextText TextText ExampleExample StepStep ExampleExample Filtering Filtering by name by name by previous by previous Execution Execution concurrent concurrent conditional conditional Reporting Reporting console console htmlhtml
  6. 6. How hard can it be? Configuration(s)Configuration(s)ResourcesResources FileSystemFileSystem “Flow”“Flow” StateState CompositionComposition ErrorsErrors
  7. 7. Problem?
  8. 8. Strategy
  9. 9. Strategy
  10. 10. Filtering by name
  11. 11. Filtering by previous TextText ExampleExample ExampleExample TextText StatsStats resultresult resultresultresultresult resultresultresultresult
  12. 12. Monad stacks Task[A]Task[A] AA ErrorError AA ErrorError AA FutureFuture
  13. 13. Monad stacks values AA ErrorError FutureFuture now(a: A) delay(a: =>A) AA ErrorError FutureFuture AA ErrorError FutureFuture fail(t: Throwable) and flatM ap! and flatM ap!
  14. 14. Action in action Action[A]Action[A] AA ErrorError AA ErrorError AA IOIO AA ErrorError IOIO ReaderReader Conf => IO[A] => IO[Error] Error = String | Throwable | (String, Throwable)
  15. 15. Action in action
  16. 16. Action opportunity Read everything!Read everything!
  17. 17. Filtering by previous TextText ExampleExample ExampleExample TextText StatsStats resultresult resultresultresultresult resultresultresultresult
  18. 18. Filtering by previous TextText ExampleExample ExampleExample TextText StatsStats resultresult Action[Fragment] => Task[Fragment] Fragment => Action[Result] Action[Result] => Action[Fragment] mapmap Task[Fragment] => Process[Task, Fragment] evaleval
  19. 19. Filtering by previous flatM ap! flatM ap!
  20. 20. Filtering by previous
  21. 21. On stacks No big deal No big deal Specialise Specialise LibraryLibrary Composition? Composition? Integration? Integration?
  22. 22. Scalaz-stream
  23. 23. Concurrency with Easy!Easy!
  24. 24. Concurrency with With state! With state! TextText ExampleExample ExampleExample StepStep ExampleExample stop herestop here
  25. 25. Flatmap with Online testing! Online testing!
  26. 26. Flatmap with Online testing! Online testing! Text1Text1 Example1Example1 Example2Example2 Example3Example3 Text1Text1 Example1Example1 Example2Example2 Example3Example3 Example2.1Example2.1 Example2.2Example2.2
  27. 27. Reporting with “duplicate” stream “duplicate” stream Write to console Write to console Accumulate state Accumulate state
  28. 28. Reporting with Text1Text1 Example1Example1 Example2Example2 Example3Example3 “t1”“t1” “e1”“e1” “e2”“e2” “e3”“e3” > Console statsstats statsstats statsstats
  29. 29. Reporting with Not composable  Not composable 
  30. 30. Reporting with and Folds!
  31. 31. Reporting with and Folds!
  32. 32. Reporting with and Folds! Opaque dependent typeOpaque dependent type
  33. 33. Reporting with and Folds! Fold Monoid! Fold Monoid!
  34. 34. Reporting with and Folds!
  35. 35. Conclusion

×