際際滷

際際滷Share a Scribd company logo
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
by name
by name
by previous
by previous
Execution
Execution
concurrent
concurrent
conditional
conditional
Reporting
Reporting
console
console
htmlhtml
How hard can it be?
Configuration(s)Configuration(s)ResourcesResources
FileSystemFileSystem
FlowFlow
StateState
CompositionComposition
ErrorsErrors
Problem?
Strategy
Strategy
Filtering by name
Filtering by previous
TextText ExampleExample ExampleExample TextText
StatsStats
resultresult
resultresultresultresult
resultresultresultresult
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
FutureFuture
fail(t: Throwable)
and
flatM
ap!
and
flatM
ap!
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)
Action in action
Action opportunity
Read
everything!Read
everything!
Filtering by previous
TextText ExampleExample ExampleExample TextText
StatsStats
resultresult
resultresultresultresult
resultresultresultresult
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
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 Example1Example1 Example2Example2 Example3Example3
Example2.1Example2.1 Example2.2Example2.2
Reporting with
duplicate
stream
duplicate
stream
Write to
console
Write to
console
Accumulate
state
Accumulate
state
Reporting with
Text1Text1 Example1Example1 Example2Example2 Example3Example3
t1t1 e1e1 e2e2 e3e3
> Console
statsstats statsstats statsstats
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
Ad

Recommended

Guava Overview. Part 1 @ Bucharest JUG #1
Guava Overview. Part 1 @ Bucharest JUG #1
Andrei Savu
Data Storage Formats in Hadoop
Data Storage Formats in Hadoop
Botond Bal叩zs
Stacks
Stacks
Sadaf Ismail
Flavour of meta-programming with shapeless
Flavour of meta-programming with shapeless
Arthur Kushka
Basic of python for data analysis
Basic of python for data analysis
Pramod Toraskar
PyData NYC whatsnew NumPy-SciPy 2019
PyData NYC whatsnew NumPy-SciPy 2019
Ralf Gommers
Python pandas Library
Python pandas Library
Md. Sohag Miah
Aftermath of functional programming. the good parts
Aftermath of functional programming. the good parts
Guillermo Guti辿rrez
ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin Odersky
Typesafe
Codemotion akka vol坦 sobre el nido del future
Codemotion akka vol坦 sobre el nido del future
Javier Santos Paniego
Codemotion 2015 - Akka vol坦 sobre el nido del future
Codemotion 2015 - Akka vol坦 sobre el nido del future
scalerablog
Functional programming in Scala
Functional programming in Scala
datamantra
Fp for the oo programmer
Fp for the oo programmer
Shawn Button
Introductiontoprogramminginscala
Introductiontoprogramminginscala
Amuhinda Hungai
Lecture1
Lecture1
Muhammad Fayyaz
An introduction to scala
An introduction to scala
Xing
Functional Stream Processing with Scalaz-Stream
Functional Stream Processing with Scalaz-Stream
Adil Akhter
Knolx Session : Built-In Control Structures in Scala
Knolx Session : Built-In Control Structures in Scala
Ayush Mishra
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2
Philip Schwarz
Intro to Scala
Intro to Scala
manaswinimysore
Scala training workshop 02
Scala training workshop 02
Nguyen Tuan
Demystifying functional programming with Scala
Demystifying functional programming with Scala
Denis
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNightHyderabad
Scala ntnu
Scala ntnu
Alf Kristian St淡yle
Intro to Functional Programming
Intro to Functional Programming
Jordan Parmer
Functional Programming in Scala 1st Edition Paul Chiusano
Functional Programming in Scala 1st Edition Paul Chiusano
sturledemsar
Meet scala
Meet scala
Wojciech Pitua
Making our Future better
Making our Future better
legendofklang
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software

More Related Content

Similar to Specs2 - Lamdbajam 2014 (20)

ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin Odersky
Typesafe
Codemotion akka vol坦 sobre el nido del future
Codemotion akka vol坦 sobre el nido del future
Javier Santos Paniego
Codemotion 2015 - Akka vol坦 sobre el nido del future
Codemotion 2015 - Akka vol坦 sobre el nido del future
scalerablog
Functional programming in Scala
Functional programming in Scala
datamantra
Fp for the oo programmer
Fp for the oo programmer
Shawn Button
Introductiontoprogramminginscala
Introductiontoprogramminginscala
Amuhinda Hungai
Lecture1
Lecture1
Muhammad Fayyaz
An introduction to scala
An introduction to scala
Xing
Functional Stream Processing with Scalaz-Stream
Functional Stream Processing with Scalaz-Stream
Adil Akhter
Knolx Session : Built-In Control Structures in Scala
Knolx Session : Built-In Control Structures in Scala
Ayush Mishra
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2
Philip Schwarz
Intro to Scala
Intro to Scala
manaswinimysore
Scala training workshop 02
Scala training workshop 02
Nguyen Tuan
Demystifying functional programming with Scala
Demystifying functional programming with Scala
Denis
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNightHyderabad
Scala ntnu
Scala ntnu
Alf Kristian St淡yle
Intro to Functional Programming
Intro to Functional Programming
Jordan Parmer
Functional Programming in Scala 1st Edition Paul Chiusano
Functional Programming in Scala 1st Edition Paul Chiusano
sturledemsar
Meet scala
Meet scala
Wojciech Pitua
Making our Future better
Making our Future better
legendofklang
ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin Odersky
Typesafe
Codemotion akka vol坦 sobre el nido del future
Codemotion akka vol坦 sobre el nido del future
Javier Santos Paniego
Codemotion 2015 - Akka vol坦 sobre el nido del future
Codemotion 2015 - Akka vol坦 sobre el nido del future
scalerablog
Functional programming in Scala
Functional programming in Scala
datamantra
Fp for the oo programmer
Fp for the oo programmer
Shawn Button
Introductiontoprogramminginscala
Introductiontoprogramminginscala
Amuhinda Hungai
An introduction to scala
An introduction to scala
Xing
Functional Stream Processing with Scalaz-Stream
Functional Stream Processing with Scalaz-Stream
Adil Akhter
Knolx Session : Built-In Control Structures in Scala
Knolx Session : Built-In Control Structures in Scala
Ayush Mishra
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2
Philip Schwarz
Scala training workshop 02
Scala training workshop 02
Nguyen Tuan
Demystifying functional programming with Scala
Demystifying functional programming with Scala
Denis
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNightHyderabad
Intro to Functional Programming
Intro to Functional Programming
Jordan Parmer
Functional Programming in Scala 1st Edition Paul Chiusano
Functional Programming in Scala 1st Edition Paul Chiusano
sturledemsar
Making our Future better
Making our Future better
legendofklang

Recently uploaded (20)

Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
Ad

Specs2 - Lamdbajam 2014

Editor's Notes

  • #3: 3 years of specs1, 4 years of specs2 Html output: I suck at html / javascript Open Source = find people! Clinton -> new design, new CSS But implementation: ugh Simplification / Composition / extension What about being pure
  • #4: Lots of possibilities More knowledge What happened: Success or Failure? This is eventually looking good and possibly looking fantastic
  • #6: Simple structure: But complex execution model -> even not enough separation between declaration and run And several functionalities on top - by tag -> read command line - by previous -> read files Execution: - must respect steps! - must be fully concurrent Reporting: - console must flow! - statistics must be stored Memory? Thread pool?
  • #9: Interested by the Cake Pattern and the ability to hide the implementation + Daniel Spiewak presentation on parametrizing it with a Monad But how far can you go with small functions?
  • #10: Use an elaborate data structure right away
  • #11: Process[Task, T] is a stream of Ts produced by a Task Process1 is like a map or filter operation A Task is an Error/Future monad stack
  • #16: Use a for comprehension Can be a bit tedious to retrofit the code like that But this is mostly a mechanical transformation And this provides a benefit
  • #17: Liberally use the configuration to influence the behaviour of your programming Thats dependency injection!
  • #22: Better than I feared In Scala you need to build a special stack for what you are doing, Reader Writer State wont work easily Build your own collection of operators to create values, fromIO, failure, Question : can you keep Configuration modular? Question: how to operate with another stack like Action <-> Task
  • #23: Use an elaborate data structure right away
  • #30: Not composable because the fragments are going to be executed twice
  • #32: Use a Fold to accumulate state
  • #36: Stacks not too hard to use Streamz a very powerful model, but very recent library and might need to come up with Folds for additional composition Being Functional = Honest brings opportunities - inject anything anywhere - careful execution model + flatmap == better execution control