Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Types Working
For You
Richard Dallaway, @d6y
underscore.io
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese an...
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practi...
Modern type system
with lots of power
Two Themes
Straightforward Scala
Types Working for Us
Progression
Part 1 Straightforward Scala
Part 2 Functional Programming
Part 3 Typelevel Programming
Straightforward Scala
— Part 1 —
The only problem was we had no idea what the code
was doing at first.
We came across a strange symbol we hadn’t seen in
ou...
The only problem was we had no idea what the code
was doing at first.
We came across a strange symbol we hadn’t seen in
ou...
The only problem was we had no idea what the code
was doing at first.
We came across a strange symbol we hadn’t seen in
ou...
The only problem was we had no idea what the code
was doing at first.
We came across a strange symbol we hadn’t seen in
ou...
“It’s about having a maintainable
code base where you can have 

people cross projects easily and
get new hires up to spee...
Power!
Protect the team from it
and
Get the benefit of it
What can we do?
1. Expressions, types, & values
2. Objects and classes
3. Algebraic data types
4. Structural recursion
5. Sequencing compu...
1. Expressions, types, & values
2. Objects and classes
3. Algebraic data types
4. Structural recursion
5. Sequencing compu...
Algebraic data types
Structural recursion
Algebraic data types
data into code
Structural recursion
transformation
Model data with logical
ors and logical ands
A website visitor is:
• anonymous; or
• logged in
A logged in user has:
• an ID; and
• facts we know about
them
Two Patterns
and (product types)
or (sum types)
Sum and product together
make algebraic data types
Structure of the code
follows the structure of
the data
A website visitor is:
• anonymous; or
• logged in
sealed trait Visitor
case class Anonymous()

extends Visitor
case class User()

extends Visitor
A logged in user has:
• an ID; and
• facts we know about
them

An anonymous has:
• an ID
sealed trait Visitor
case class Anonymous()

extends Visitor
case class User()

extends Visitor
sealed trait Visitor
case class Anonymous(id: Id)

extends Visitor
case class User(id: Id, facts: Set[Fact])

extends Visi...
Structural recursion
def serveAd(v: Visitor): Advert = ???
Structure of the code
follows the structure of
the data
def serveAd(v: Visitor): Advert = ???
def serveAd(v: Visitor): Advert =
v match {
case User(_, info) => relevantAd(info)
case Anonymous(id) => adRotation(id)
}
def serveAd(v: Visitor): Advert =
v match {
case User(_, info) => relevantAd(info)
case Anonymous(id) => adRotation(id)
}
def serveAd(v: Visitor): Advert =
v match {
case User(_, info) => relevantAd(info)
case Anonymous(id) => adRotation(id)
}
...
ADT & Structural Recursion
Straightforward part of Scala.
Clear, productive, occurs frequently.
Be opinionated in what you...
Help from FP Ideas
— Part 2 —
Combining lists
Concatenating strings
Union of sets
Combining things in a loop
Chaining logical operations
Adding numbers
...
A combine function and
an empty value
Addition
Empty Combine
0 +
Set
Empty Combine
Set.empty union
For any T
Empty Combine
A zero for T
A way to
combine two Ts
and give me
back a T
A combine function and
an empty value
Monoid
A combine function and
an empty value
…and laws
The boss asks…
What’s the total visits to the web site?
def report(vs: List[Int]): Int = ???
For any T
Empty Combine
A zero for T
A way to
combine two Ts
and give me
back a T
For any T
trait Monoid[T] {
def empty: T
def combine(x: T, y: T): T
}
val addition = new Monoid[Int] {
def empty = 0
def combine(x: Int, y: Int) = x+y
}
fold
def fold(vs: List[Int]): Int =
vs match {
case Nil => 0
case v :: rest => v + fold(rest)
}
fold(List(1,2,3))

// 6
fold(1,2,3)
1 + fold(2,3)
2 + fold(3)
3 + fold()
0
0 + 3 + 2 + 1 = 6
fold(1,2,3)
1 + fold(2,3)
2 + fold(3)
3 + fold()
0
0 + 3 + 2 + 1 = 6
fold(1,2,3)
1 + fold(2,3)
2 + fold(3)
3 + fold()
0
0 + 3 + 2 + 1 = 6
fold(1,2,3)
1 + fold(2,3)
2 + fold(3)
3 + fold()
0
0 + 3 + 2 + 1 = 6
fold(1,2,3)
1 + fold(2,3)
2 + fold(3)
3 + fold()
0
0 + 3 + 2 + 1 = 6
fold(1,2,3)
1 + fold(2,3)
2 + fold(3)
3 + fold()
0
0 + 3 + 2 + 1 = 6
def fold(vs: List[Int]): Int =
vs match {
case Nil => 0
case v :: rest => v + fold(rest)
}
fold(List(1,2,3))

// 6
def fold(vs: List[Int], m: Monoid[Int]): Int =
vs match {
case Nil => 0
case v :: rest => v + fold(rest)
}
fold(List(1,2,3...
def fold(vs: List[Int], m: Monoid[Int]): Int =
vs match {
case Nil => m.empty
case v :: rest => m.combine(v, fold(rest,m))...
def fold[T](vs: List[T], m: Monoid[T]): T =
vs match {
case Nil => m.empty
case v :: rest => m.combine(v, fold(rest,m))
}
...
Split on cases,
inspect values you have
def fold[T](vs: List[T], m: Monoid[T]): T =
vs match {
case Nil => ???
case v :: rest => ???
}
fold(List(1,2,3), addition)...
def fold[T](vs: List[T], m: Monoid[T]): T =
vs match {
case Nil => m.empty
case v :: rest => ???
}
fold(List(1,2,3), addit...
But back to Monoids…
The boss asks…
What’s the total visits to the web site?
def report(vs: List[Int]): Int =
fold(vs, addition)
Benefits
Composition
Flexibility
Problem Solving
The boss asks…
How many distinct visitors?
def report(vs: List[Visitor]): Int = ???
Set
Empty Combine
Set.empty union
The boss says…
Argh! 

The servers are OutOfMemory
HyperLogLog
Empty Combine
new HLL() HLL.plus
Armon Dadgar (Papers We Love, 2015)

“Bloom Filters and HyperLogLog”
The boss asks…
Who are the really keen 

visitors to the site?
Count-Min Sketch
Empty Combine
new CMS() CMS.plus
Laura Bledaite (Scala eXchange 2015) 

“Count-Min Sketch in Real Data Ap...
We can safely run 

a parallel version 

of fold
Laws
a + 0 = a
(a + b) + c = a + (b + c)
Identity & Associativity
a combine empty = a
(a combine b) combine c 

= a combine (b combine c)
a combine b
combine combine
c d e f
Errors: 10 Warnings: 0
Its a monoid
I know this
…so we fold
Summary
Types and laws give us flexibility &
help lead us to solutions.
They help us every day.
A Taste of Typelevel
— Part 3 —
Date Metric
Mon Low
Tue High
csv(
List(“Date”, “Metric”),
List(
List(“Mon”, “Low”),
List(“Tue”, “High”) )
)
Date
Mon Low
Tue High
csv(
List(“Date”),
List(
List(“Mon”, “Low”),
List(“Tue”, “High”) )
)
How can we prevent that error
happening again?
def csv(
hdrs: List[String],
rows: List[List[String]]
): String = ???
def csv[N <: Nat](
hdrs: List[String],
rows: List[List[String]]
): String = ???
import shapeless._
import syntax.sized._
def csv[N <: Nat](
hdrs: Sized[List[String], N],
rows: List[Sized[List[String], N]]
): String = ???
import shapeless._
imp...
csv(
Sized(“Date”),
List(
Sized(“Mon”, “Low”),
Sized(“Tue”, “High”) )
)
csv(
Sized(“Date”),
List(
Sized(“Mon”, “Low”),
Sized(“Tue”, “High”) )
)
Sized[List, 1]
Sized[List, 2]
How?
Sized(“Date”) constructs
Sized[Nat]
Nat implements numbers as
types
sealed trait Nat
trait Succ[P <: Nat] extends Nat
trait Zero extends Nat
Zero 0
Succ[Zero] 1
Succ[Succ[Zero]] 2
Succ[Succ[Succ[Zero]]] 3
sealed trait Nat
trait Succ[P <: Nat] extends Nat
trait Zero extends Nat
sealed trait Nat
trait Succ[P <: Nat] extends Nat
trait Zero extends Nat
type One = Succ[Zero]
type Two = Succ[One]
implic...
sealed trait Nat
trait Succ[P <: Nat] extends Nat
trait Zero extends Nat
type One = Succ[Zero]
type Two = Succ[One]
implic...
sealed trait Nat
trait Succ[P <: Nat] extends Nat
trait Zero extends Nat
type One = Succ[Zero]
type Two = Succ[One]
implic...
sealed trait Nat
trait Succ[P <: Nat] extends Nat
trait Zero extends Nat
type One = Succ[Zero]
type Two = Succ[One]
implic...
Merging Fields
case class User(

id : Long,

name : String,

email : Option[String])
val user = User(

123L, 

“Bruce Wayne”,

Some(“bruc...
PATCH /user/123
{

“name” : “Batman”

}
case class User(

id : Long,

name : String,

email : Option[String])
case class Update(

name : Option[String],

email : ...
val user = User(

123L, 

“Bruce Wayne”,

Some(“bruce@example.org”))
val update = Update( 

Some(“Batman”), 

None)
How do...
Bulletin
https://github.com/davegurnell/bulletin
How?
User String Option[String] …
Option[String]
Option[

Option[String]
]
…Update
How?
User String Option[String] …
Option[String]
Option[

Option[String]
]
…Update
Head
How?
User String Option[String] …
Option[String]
Option[

Option[String]
]
…Update
Head The Rest…
How?
Type constraints
Implicit methods
HLists
Labelled generic
Macros
…
val user = User(

123L, 

"Bruce Wayne”,

Some(“bruce@example.org”))
val update = Update( 

Some(“Batman”), 

None)
import...
val user = User(

123L, 

"Bruce Wayne”,

Some(“bruce@example.org”))
val update = Update( 

Some(“Batman”), 

None)
import...
Summary
The compiler can help (maybe more than
you thought).
Reduce boilerplate code.
Using Power Tools
Can go one of two ways…
Using Power Tools
Can go one of two ways…
What the hell
is that?
It’s a monoid!

I know this
Simple
Types
Power
Share
2008
‘The name Scala stands for
“scalable language.”



The language is so named
because it was designed
to grow with the ...
What have we seen?
Some straightforward parts of Scala

—Clear, maintainable, helpful
Encoding ideas in types

—flexibility...
Summary
Scala scaling with your needs

—be opinionated in what you use, more when needed
Types working for us, not stoppin...
Thanks!
Richard Dallaway, @d6y
underscore.io
Thanks!
Richard Dallaway, @d6y
underscore.io
Amanda Laucher
Wesley Reisz
Noel Welsh
Dave Gurnell
Miles Sabin
Jono Ferguson...
Watch the video with slide synchronization on
InfoQ.com!
http://www.infoq.com/presentations/scala-
patterns-types
Types Working for You, Not Against You
Types Working for You, Not Against You
Types Working for You, Not Against You
Types Working for You, Not Against You
Prochain SlideShare
Chargement dans…5
×

Types Working for You, Not Against You

164 vues

Publié le

Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/1ZW7TDL.

Richard Dallaway shows an example of what Scala looks like when using pattern matching over classes, how to encode an idea into types and use advanced features of Scala without complicating the code. Filmed at qconlondon.com.

Richard Dallaway is a partner at Underscore -- a consultancy specializing in Scala, especially the type-driven and functional aspects of Scala. He works on client projects writing software and helping teams deliver software with Scala. His focus is on the web, machine learning, and code review. He's the co-author of "Essential Slick" (Underscore), and author of the "Lift Cookbook" (O'Reilly).

Publié dans : Technologie
  • Soyez le premier à commenter

Types Working for You, Not Against You

  1. 1. Types Working For You Richard Dallaway, @d6y underscore.io
  2. 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /scala-patterns-types
  3. 3. Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide Presented at QCon London www.qconlondon.com
  4. 4. Modern type system with lots of power
  5. 5. Two Themes Straightforward Scala Types Working for Us
  6. 6. Progression Part 1 Straightforward Scala Part 2 Functional Programming Part 3 Typelevel Programming
  7. 7. Straightforward Scala — Part 1 —
  8. 8. The only problem was we had no idea what the code was doing at first. We came across a strange symbol we hadn’t seen in our projects before The spaceship operator <|*|> Someone said out loud “what the hell is that?” http://jimplush.com/talk/
  9. 9. The only problem was we had no idea what the code was doing at first. We came across a strange symbol we hadn’t seen in our projects before The spaceship operator <|*|> Someone said out loud “what the hell is that?” http://jimplush.com/talk/
  10. 10. The only problem was we had no idea what the code was doing at first. We came across a strange symbol we hadn’t seen in our projects before The spaceship operator <|*|> Someone said out loud “what the hell is that?” http://jimplush.com/talk/
  11. 11. The only problem was we had no idea what the code was doing at first. We came across a strange symbol we hadn’t seen in our projects before The spaceship operator <|*|> Someone said out loud “what the hell is that?” http://jimplush.com/talk/
  12. 12. “It’s about having a maintainable code base where you can have 
 people cross projects easily and get new hires up to speed rapidly”
  13. 13. Power! Protect the team from it and Get the benefit of it
  14. 14. What can we do?
  15. 15. 1. Expressions, types, & values 2. Objects and classes 3. Algebraic data types 4. Structural recursion 5. Sequencing computation 6. Type classes
  16. 16. 1. Expressions, types, & values 2. Objects and classes 3. Algebraic data types 4. Structural recursion 5. Sequencing computation 6. Type classes
  17. 17. Algebraic data types Structural recursion
  18. 18. Algebraic data types data into code Structural recursion transformation
  19. 19. Model data with logical ors and logical ands
  20. 20. A website visitor is: • anonymous; or • logged in
  21. 21. A logged in user has: • an ID; and • facts we know about them
  22. 22. Two Patterns and (product types) or (sum types) Sum and product together make algebraic data types
  23. 23. Structure of the code follows the structure of the data
  24. 24. A website visitor is: • anonymous; or • logged in
  25. 25. sealed trait Visitor case class Anonymous()
 extends Visitor case class User()
 extends Visitor
  26. 26. A logged in user has: • an ID; and • facts we know about them
 An anonymous has: • an ID
  27. 27. sealed trait Visitor case class Anonymous()
 extends Visitor case class User()
 extends Visitor
  28. 28. sealed trait Visitor case class Anonymous(id: Id)
 extends Visitor case class User(id: Id, facts: Set[Fact])
 extends Visitor
  29. 29. Structural recursion
  30. 30. def serveAd(v: Visitor): Advert = ???
  31. 31. Structure of the code follows the structure of the data
  32. 32. def serveAd(v: Visitor): Advert = ???
  33. 33. def serveAd(v: Visitor): Advert = v match { case User(_, info) => relevantAd(info) case Anonymous(id) => adRotation(id) }
  34. 34. def serveAd(v: Visitor): Advert = v match { case User(_, info) => relevantAd(info) case Anonymous(id) => adRotation(id) }
  35. 35. def serveAd(v: Visitor): Advert = v match { case User(_, info) => relevantAd(info) case Anonymous(id) => adRotation(id) } Structure
  36. 36. ADT & Structural Recursion Straightforward part of Scala. Clear, productive, occurs frequently. Be opinionated in what you use. Structure helps us.
  37. 37. Help from FP Ideas — Part 2 —
  38. 38. Combining lists Concatenating strings Union of sets Combining things in a loop Chaining logical operations Adding numbers Building up a JavaScript expression Showing errors in a UI ...
  39. 39. A combine function and an empty value
  40. 40. Addition Empty Combine 0 +
  41. 41. Set Empty Combine Set.empty union
  42. 42. For any T Empty Combine A zero for T A way to combine two Ts and give me back a T
  43. 43. A combine function and an empty value
  44. 44. Monoid A combine function and an empty value …and laws
  45. 45. The boss asks… What’s the total visits to the web site? def report(vs: List[Int]): Int = ???
  46. 46. For any T Empty Combine A zero for T A way to combine two Ts and give me back a T
  47. 47. For any T trait Monoid[T] { def empty: T def combine(x: T, y: T): T }
  48. 48. val addition = new Monoid[Int] { def empty = 0 def combine(x: Int, y: Int) = x+y }
  49. 49. fold
  50. 50. def fold(vs: List[Int]): Int = vs match { case Nil => 0 case v :: rest => v + fold(rest) } fold(List(1,2,3))
 // 6
  51. 51. fold(1,2,3) 1 + fold(2,3) 2 + fold(3) 3 + fold() 0 0 + 3 + 2 + 1 = 6
  52. 52. fold(1,2,3) 1 + fold(2,3) 2 + fold(3) 3 + fold() 0 0 + 3 + 2 + 1 = 6
  53. 53. fold(1,2,3) 1 + fold(2,3) 2 + fold(3) 3 + fold() 0 0 + 3 + 2 + 1 = 6
  54. 54. fold(1,2,3) 1 + fold(2,3) 2 + fold(3) 3 + fold() 0 0 + 3 + 2 + 1 = 6
  55. 55. fold(1,2,3) 1 + fold(2,3) 2 + fold(3) 3 + fold() 0 0 + 3 + 2 + 1 = 6
  56. 56. fold(1,2,3) 1 + fold(2,3) 2 + fold(3) 3 + fold() 0 0 + 3 + 2 + 1 = 6
  57. 57. def fold(vs: List[Int]): Int = vs match { case Nil => 0 case v :: rest => v + fold(rest) } fold(List(1,2,3))
 // 6
  58. 58. def fold(vs: List[Int], m: Monoid[Int]): Int = vs match { case Nil => 0 case v :: rest => v + fold(rest) } fold(List(1,2,3), addition)
 // 6
  59. 59. def fold(vs: List[Int], m: Monoid[Int]): Int = vs match { case Nil => m.empty case v :: rest => m.combine(v, fold(rest,m)) } fold(List(1,2,3), addition)
 // 6
  60. 60. def fold[T](vs: List[T], m: Monoid[T]): T = vs match { case Nil => m.empty case v :: rest => m.combine(v, fold(rest,m)) } fold(List(1,2,3), addition)
 // 6
  61. 61. Split on cases, inspect values you have
  62. 62. def fold[T](vs: List[T], m: Monoid[T]): T = vs match { case Nil => ??? case v :: rest => ??? } fold(List(1,2,3), addition)
 // 6
  63. 63. def fold[T](vs: List[T], m: Monoid[T]): T = vs match { case Nil => m.empty case v :: rest => ??? } fold(List(1,2,3), addition)
 // 6
  64. 64. But back to Monoids…
  65. 65. The boss asks… What’s the total visits to the web site? def report(vs: List[Int]): Int = fold(vs, addition)
  66. 66. Benefits Composition Flexibility Problem Solving
  67. 67. The boss asks… How many distinct visitors? def report(vs: List[Visitor]): Int = ???
  68. 68. Set Empty Combine Set.empty union
  69. 69. The boss says… Argh! 
 The servers are OutOfMemory
  70. 70. HyperLogLog Empty Combine new HLL() HLL.plus Armon Dadgar (Papers We Love, 2015)
 “Bloom Filters and HyperLogLog”
  71. 71. The boss asks… Who are the really keen 
 visitors to the site?
  72. 72. Count-Min Sketch Empty Combine new CMS() CMS.plus Laura Bledaite (Scala eXchange 2015) 
 “Count-Min Sketch in Real Data Applications”
  73. 73. We can safely run 
 a parallel version 
 of fold
  74. 74. Laws
  75. 75. a + 0 = a (a + b) + c = a + (b + c)
  76. 76. Identity & Associativity a combine empty = a (a combine b) combine c 
 = a combine (b combine c)
  77. 77. a combine b combine combine c d e f
  78. 78. Errors: 10 Warnings: 0
  79. 79. Its a monoid I know this
  80. 80. …so we fold
  81. 81. Summary Types and laws give us flexibility & help lead us to solutions. They help us every day.
  82. 82. A Taste of Typelevel — Part 3 —
  83. 83. Date Metric Mon Low Tue High csv( List(“Date”, “Metric”), List( List(“Mon”, “Low”), List(“Tue”, “High”) ) )
  84. 84. Date Mon Low Tue High csv( List(“Date”), List( List(“Mon”, “Low”), List(“Tue”, “High”) ) )
  85. 85. How can we prevent that error happening again?
  86. 86. def csv( hdrs: List[String], rows: List[List[String]] ): String = ???
  87. 87. def csv[N <: Nat]( hdrs: List[String], rows: List[List[String]] ): String = ??? import shapeless._ import syntax.sized._
  88. 88. def csv[N <: Nat]( hdrs: Sized[List[String], N], rows: List[Sized[List[String], N]] ): String = ??? import shapeless._ import syntax.sized._
  89. 89. csv( Sized(“Date”), List( Sized(“Mon”, “Low”), Sized(“Tue”, “High”) ) )
  90. 90. csv( Sized(“Date”), List( Sized(“Mon”, “Low”), Sized(“Tue”, “High”) ) ) Sized[List, 1] Sized[List, 2]
  91. 91. How? Sized(“Date”) constructs Sized[Nat] Nat implements numbers as types
  92. 92. sealed trait Nat trait Succ[P <: Nat] extends Nat trait Zero extends Nat
  93. 93. Zero 0 Succ[Zero] 1 Succ[Succ[Zero]] 2 Succ[Succ[Succ[Zero]]] 3
  94. 94. sealed trait Nat trait Succ[P <: Nat] extends Nat trait Zero extends Nat
  95. 95. sealed trait Nat trait Succ[P <: Nat] extends Nat trait Zero extends Nat type One = Succ[Zero] type Two = Succ[One] implicitly[Succ[Zero] =:= One] implicitly[Succ[One] =:= Succ[Succ[Zero]]]
  96. 96. sealed trait Nat trait Succ[P <: Nat] extends Nat trait Zero extends Nat type One = Succ[Zero] type Two = Succ[One] implicitly[Succ[Zero] =:= One] implicitly[Succ[One] =:= Succ[Succ[Zero]]]
  97. 97. sealed trait Nat trait Succ[P <: Nat] extends Nat trait Zero extends Nat type One = Succ[Zero] type Two = Succ[One] implicitly[Succ[Zero] =:= One] implicitly[Succ[One] =:= Succ[Succ[Zero]]]
  98. 98. sealed trait Nat trait Succ[P <: Nat] extends Nat trait Zero extends Nat type One = Succ[Zero] type Two = Succ[One] implicitly[Succ[Zero] =:= Two] error: Cannot prove that Succ[Zero] =:= Two.
  99. 99. Merging Fields
  100. 100. case class User(
 id : Long,
 name : String,
 email : Option[String]) val user = User(
 123L, 
 “Bruce Wayne”,
 Some(“bruce@example.org”))
  101. 101. PATCH /user/123 {
 “name” : “Batman”
 }
  102. 102. case class User(
 id : Long,
 name : String,
 email : Option[String]) case class Update(
 name : Option[String],
 email : Option[Option[String]])
  103. 103. val user = User(
 123L, 
 “Bruce Wayne”,
 Some(“bruce@example.org”)) val update = Update( 
 Some(“Batman”), 
 None) How do we get to… User(
 123L, 
 “Batman”, 
 Some(“bruce@example.org”))
  104. 104. Bulletin https://github.com/davegurnell/bulletin
  105. 105. How? User String Option[String] … Option[String] Option[
 Option[String] ] …Update
  106. 106. How? User String Option[String] … Option[String] Option[
 Option[String] ] …Update Head
  107. 107. How? User String Option[String] … Option[String] Option[
 Option[String] ] …Update Head The Rest…
  108. 108. How? Type constraints Implicit methods HLists Labelled generic Macros …
  109. 109. val user = User(
 123L, 
 "Bruce Wayne”,
 Some(“bruce@example.org”)) val update = Update( 
 Some(“Batman”), 
 None) import bulletin._ val updated = user.merge(update) // User(
 // 123L, 
 // “Batman”, 
 // Some(“bruce@example.org”))
  110. 110. val user = User(
 123L, 
 "Bruce Wayne”,
 Some(“bruce@example.org”)) val update = Update( 
 Some(“Batman”), 
 None) import bulletin._ val updated = user.merge(update) // User(
 // 123L, 
 // “Batman”, 
 // Some(“bruce@example.org”))
  111. 111. Summary The compiler can help (maybe more than you thought). Reduce boilerplate code.
  112. 112. Using Power Tools Can go one of two ways…
  113. 113. Using Power Tools Can go one of two ways… What the hell is that? It’s a monoid!
 I know this
  114. 114. Simple Types Power Share
  115. 115. 2008 ‘The name Scala stands for “scalable language.”
 
 The language is so named because it was designed to grow with the demands of its users.’
  116. 116. What have we seen? Some straightforward parts of Scala
 —Clear, maintainable, helpful Encoding ideas in types
 —flexibility, leads us to solutions
 
 Let the compiler do it 
 —when it make sense for your demands
  117. 117. Summary Scala scaling with your needs
 —be opinionated in what you use, more when needed Types working for us, not stopping us
 —functional programming, share what you learn
  118. 118. Thanks! Richard Dallaway, @d6y underscore.io
  119. 119. Thanks! Richard Dallaway, @d6y underscore.io Amanda Laucher Wesley Reisz Noel Welsh Dave Gurnell Miles Sabin Jono Ferguson Julio Capote Alessandro Zoffoli
  120. 120. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/scala- patterns-types

×