SlideShare a Scribd company logo
Implicits	Inspected	and
Explained
ScalaDays	2016	Berlin
Tim	Soethout	-	ING	Bank
http://blog.timmybankers.nl
Implicits	Inspected	and
Explained
ScalaDays	2016	Berlin
Tim	Soethout	-	ING	Bank
Outline:	Introduction	-	Implicits	-	Resolving	-	Type	Classes	-	Wrap	up
http://blog.timmybankers.nl
About	myself
Tim	Soethout
Functional	programmer	at	heart
Scala/FP	evangelist/trainer	inside	ING	Bank
PhD	Candidate
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
What?
Use	values	without	explicit	reference
OO:	is	a	+	has	a
Implicits	add:	is	viewable	as	a
Loose	Coupling,	Tight	Cohesion
Examples
Akka
Futures
trait ScalaActorRef
def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = ...
}
actorRef ! SomeMessage("text")
object Future {
def apply[T](body: =>T)(implicit executor: ExecutionContext): Future[T] = ...
}
Future {
doExpensiveComputation()
}
Examples	(2)
Collections
trait TraversableOnce[+A] {
def sum[B >: A](implicit num: Numeric[B]): B = ...
}
List(1,2,3).sum
res0: Int = 6
Examples	(3)
Finagle
@implicitNotFound("Builder is not fully configured: Cluster: ${HasCluster}, Codec: ${HasCodec},
HostConnectionLimit: ${HasHostConnectionLimit}")
private[builder] trait ClientConfigEvidence[HasCluster, HasCodec, HasHostConnectionLimit]
class ClientBuilder[Req, Rep, HasCluster, HasCodec, HasHostConnectionLimit] private[finagle](...) {
def build()(
implicit THE_BUILDER_IS_NOT_FULLY_SPECIFIED_SEE_ClientBuilder_DOCUMENTATION:
ClientConfigEvidence[HasCluster, HasCodec, HasHostConnectionLimit]
): Service[Req, Rep] = ...
}
val builder: ClientBuilder[Request, Response, Yes, Yes, Nothing] =
ClientBuilder()
.codec(Http())
.hosts("twitter.com:80")
builder.build()
Error:(24, 15) Builder is not fully configured: Cluster: com.twitter.finagle.builder.ClientConfig.Yes,
Codec: com.twitter.finagle.builder.ClientConfig.Yes, HostConnectionLimit: Nothing
builder.build()
^
Implicits	enable
DSLs
Type	evidence
Reduce	verbosity
Type	classes
Dependency	Injection	at	Compile	time
Extending	libraries
But	beware
Resolution	rules	can	be	difficult
Automatic	conversions
Do	not	overuse
Demo
Implicit	conversions	(a.k.a.	Implicit	views)
Implicit	parameters
Implicit	classes
Implicit	declarations
implicit def a2B(a : A) : B = ...
def method(implicit x : Int) = ...
implicit class X(y: Int)
implicit val x = ...
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Scoping
Odersky	Explains
Lookup	precedence:
1.	 By	name	only,	without	any	prefix
2.	 In	"implicit	scope":
companion/package	object	of
the	source	type
its	parameters	+	supertype	and	supertraits
Demo
Scoping	and	resolving
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Typeclass	uses
Ad-hoc	polymorphism
Extension	of	libraries
trait Numeric[T] extends Ordering[T] {
def plus(x: T, y: T): T
def minus(x: T, y: T): T
def times(x: T, y: T): T
...
}
Demo
Typeclass	for	JSON	Serialisation
Naive	with	subtyping
Typeclass	+	improvements
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Implicits Inspected and Explained @ ScalaDays 2016 Berlin
Recap
Implicits	are	powerful
Be	careful	with	conversions
Implicit	precedence:	first	look	local,	then	in	companion/package	object
Typeclasses	to	extend	libraries
Recap
Implicits	are	powerful
Be	careful	with	conversions
Implicit	precedence:	first	look	local,	then	in	companion/package	object
Typeclasses	to	extend	libraries
Questions?
Tim	Soethout	@	ScalaDays	2016	Berlin
References
	/	
Scala	documentation:
Book:	
Blog	
,	special	thanks	to	@Ichoran	and	@som-snytt
,	for	the	demo	slides
http://blog.timmybankers.nl
Slides Code
Java	Converters
Finding	Implicits
Scala	In	Depth
Effective	Scala
All	Things	Runnable
Scala	Gitter	channel
REPLesent

More Related Content

ODP
jTransfo quickie at JavaZone 2015
ODP
Datatype in JavaScript
PDF
Confident Ruby: Be A Coding Hemingway
PDF
Introduction to Smalltalk
PDF
Smalltalk, the dynamic language
PDF
Variables in Pharo5
PPT
JavaScript Data Types
ODP
Objectivec vs swift
jTransfo quickie at JavaZone 2015
Datatype in JavaScript
Confident Ruby: Be A Coding Hemingway
Introduction to Smalltalk
Smalltalk, the dynamic language
Variables in Pharo5
JavaScript Data Types
Objectivec vs swift

What's hot (14)

PDF
linq with Exampls
PPTX
05 functional programming
PPT
On Scala Slides - OSDC 2009
PDF
Migrating Objective-C to Swift
PDF
A Journey From Objective C to Swift - Chromeinfotech
PDF
A Deep Dive into Javascript
PPTX
Exploring C# DSLs: LINQ, Fluent Interfaces and Expression Trees
PPTX
Creating classes in code (Syntax)
PPTX
2CPP03 - Object Orientation Fundamentals
POTX
Introduction to php 4
PDF
Crystal: tipos, peculiaridades y desafios
PPTX
JavaScript operators
PDF
Advanced PHP Simplified
PPTX
Introduction to f#
linq with Exampls
05 functional programming
On Scala Slides - OSDC 2009
Migrating Objective-C to Swift
A Journey From Objective C to Swift - Chromeinfotech
A Deep Dive into Javascript
Exploring C# DSLs: LINQ, Fluent Interfaces and Expression Trees
Creating classes in code (Syntax)
2CPP03 - Object Orientation Fundamentals
Introduction to php 4
Crystal: tipos, peculiaridades y desafios
JavaScript operators
Advanced PHP Simplified
Introduction to f#
Ad

Similar to Implicits Inspected and Explained @ ScalaDays 2016 Berlin (20)

PDF
Implicits Inspected and Explained
PPTX
Oop2010 Scala Presentation Stal
PDF
Functional programming in C++
PPTX
13_User_Defined_Objects.pptx objects in javascript
PPTX
Javazone 2010-lift-framework-public
PDF
Scala and Spring
PPTX
Introduction to Spark ML
PDF
Angular 2 Essential Training
PDF
Solving performance issues in Django ORM
PPTX
What`s New in Java 8
PPT
Dublin Core Basic Syntax Tutorial
PDF
Exploring type level programming in Scala
PDF
Prompt engineering for iOS developers (How LLMs and GenAI work)
PPT
Oop java
PDF
Ad-hoc Runtime Object Structure Visualizations with MetaLinks
PDF
Spring Day | Spring and Scala | Eberhard Wolff
PPTX
Qcon2011 functions rockpresentation_scala
PDF
Introduction to Asynchronous scala
PDF
Applicative Functor - Part 2
PDF
Programming Languages: some news for the last N years
Implicits Inspected and Explained
Oop2010 Scala Presentation Stal
Functional programming in C++
13_User_Defined_Objects.pptx objects in javascript
Javazone 2010-lift-framework-public
Scala and Spring
Introduction to Spark ML
Angular 2 Essential Training
Solving performance issues in Django ORM
What`s New in Java 8
Dublin Core Basic Syntax Tutorial
Exploring type level programming in Scala
Prompt engineering for iOS developers (How LLMs and GenAI work)
Oop java
Ad-hoc Runtime Object Structure Visualizations with MetaLinks
Spring Day | Spring and Scala | Eberhard Wolff
Qcon2011 functions rockpresentation_scala
Introduction to Asynchronous scala
Applicative Functor - Part 2
Programming Languages: some news for the last N years
Ad

Recently uploaded (20)

PPTX
assetexplorer- product-overview - presentation
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
top salesforce developer skills in 2025.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Digital Strategies for Manufacturing Companies
PPTX
L1 - Introduction to python Backend.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Transform Your Business with a Software ERP System
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
assetexplorer- product-overview - presentation
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Design an Analysis of Algorithms I-SECS-1021-03
top salesforce developer skills in 2025.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Odoo Companies in India – Driving Business Transformation.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Why Generative AI is the Future of Content, Code & Creativity?
Digital Strategies for Manufacturing Companies
L1 - Introduction to python Backend.pptx
history of c programming in notes for students .pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
Transform Your Business with a Software ERP System
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Understanding Forklifts - TECH EHS Solution
Computer Software and OS of computer science of grade 11.pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf

Implicits Inspected and Explained @ ScalaDays 2016 Berlin