![Page 1: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/1.jpg)
Epic Success V Failure ? Refactoring to real FP
Eric Torreborre
![Page 2: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/2.jpg)
Why, oh why?
![Page 3: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/3.jpg)
What now?
![Page 4: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/4.jpg)
How hard can it be?
HelloWorldSpec.scala
![Page 5: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/5.jpg)
How hard can it be?
Text
Example
Text
Text
Example
Step
Example
Filtering
by nameby previous
Execution
concurre
ntcondition
al
Reporting
console
html
![Page 6: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/6.jpg)
How hard can it be?
Configuration(s)Resources
FileSystem
“Flow”
State
Composition
Errors
![Page 7: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/7.jpg)
Problem?
![Page 8: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/8.jpg)
Strategy
![Page 9: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/9.jpg)
Strategy
![Page 10: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/10.jpg)
Filtering by name
![Page 11: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/11.jpg)
Filtering by previous
Text Example Example Text
Stats
result
resultresult
resultresult
![Page 12: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/12.jpg)
Monad stacks
Task[A]
AError
AError
A
Future
![Page 13: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/13.jpg)
Monad stacks values
AError
Future
now(a: A)
delay(a: =>A)A
Error
Future
AError
Future
fail(t: Throwable)
and
flatM
ap!
![Page 14: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/14.jpg)
Action in action
Action[A]
AError
AError
A
IO
AError
IO
Reader
Conf => IO[A] => IO[Error]
Error = String | Throwable | (String, Throwable)
![Page 15: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/15.jpg)
Action in action
![Page 16: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/16.jpg)
Action opportunity
Read
everything
!
![Page 17: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/17.jpg)
Filtering by previous
Text Example Example Text
Stats
result
resultresult
resultresult
![Page 18: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/18.jpg)
Filtering by previous
Text Example Example Text
Stats
result
Action[Fragment] => Task[Fragment]
Fragment => Action[Result]Action[Result] => Action[Fragment]
map
Task[Fragment] => Process[Task, Fragment]
eval
![Page 19: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/19.jpg)
Filtering by previous
flatM
ap!
![Page 20: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/20.jpg)
Filtering by previous
![Page 21: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/21.jpg)
On stacks
No big deal
Specialise
Library
Composition?
Integration?
![Page 22: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/22.jpg)
Scalaz-stream
![Page 23: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/23.jpg)
Concurrency with
Easy!
![Page 24: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/24.jpg)
Concurrency with
With state!
Text Example Example Step Example
stop here
![Page 25: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/25.jpg)
Flatmap with
Online
testing!
![Page 26: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/26.jpg)
Flatmap with
Online
testing!
Text1 Example1 Example2 Example3
Text1 Example1 Example2 Example3
Example2.1 Example2.2
![Page 27: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/27.jpg)
Reporting with
“duplicate”stream
Write to console
Accumulatestate
![Page 28: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/28.jpg)
Reporting with
Text1 Example1 Example2 Example3
“t1” “e1” “e2” “e3”
> Console
stats stats stats
![Page 29: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/29.jpg)
Reporting with
Not composable
![Page 30: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/30.jpg)
Reporting with and Folds!
![Page 31: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/31.jpg)
Reporting with and Folds!
![Page 32: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/32.jpg)
Reporting with and Folds!
Opaque
dependent
type
![Page 33: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/33.jpg)
Reporting with and Folds!
Fold Monoid!
![Page 34: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/34.jpg)
Reporting with and Folds!
![Page 35: Epic success \/ failure, refactoring to *real* FP](https://reader036.vdocument.in/reader036/viewer/2022081412/53fde3568d7f72a81c8b4ba5/html5/thumbnails/35.jpg)
Conclusion