Epic Success V Failure ? Refactoring to real FP Eric Torreborre
Aug 27, 2014
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?
Text
Example
Text
Text
Example
Step
Example
Filtering
by nameby previous
Execution
concurre
ntcondition
al
Reporting
console
html
How hard can it be?
Configuration(s)Resources
FileSystem
“Flow”
State
Composition
Errors
Problem?
Strategy
Strategy
Filtering by name
Filtering by previous
Text Example Example Text
Stats
result
resultresult
resultresult
Monad stacks
Task[A]
AError
AError
A
Future
Monad stacks values
AError
Future
now(a: A)
delay(a: =>A)A
Error
Future
AError
Future
fail(t: Throwable)
and
flatM
ap!
Action in action
Action[A]
AError
AError
A
IO
AError
IO
Reader
Conf => IO[A] => IO[Error]
Error = String | Throwable | (String, Throwable)
Action in action
Action opportunity
Read
everything
!
Filtering by previous
Text Example Example Text
Stats
result
resultresult
resultresult
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
Filtering by previous
flatM
ap!
Filtering by previous
On stacks
No big deal
Specialise
Library
Composition?
Integration?
Scalaz-stream
Concurrency with
Easy!
Concurrency with
With state!
Text Example Example Step Example
stop here
Flatmap with
Online
testing!
Flatmap with
Online
testing!
Text1 Example1 Example2 Example3
Text1 Example1 Example2 Example3
Example2.1 Example2.2
Reporting with
“duplicate”stream
Write to console
Accumulatestate
Reporting with
Text1 Example1 Example2 Example3
“t1” “e1” “e2” “e3”
> Console
stats stats stats
Reporting with
Not composable
Reporting with and Folds!
Reporting with and Folds!
Reporting with and Folds!
Opaque
dependent
type
Reporting with and Folds!
Fold Monoid!
Reporting with and Folds!
Conclusion