SlideShare a Scribd company logo
Vampire Methods
ScalaSyd
Can you do this?
@xeno_by jumps in
Kittens!
Kittens!
Generate a local class!
Local CatMatcher
Paradise plugin
Just for quasi-quotes
Local CatMatcher
Batman
Local CatMatcher
http://stackoverflow.com/questions/18480707/method-cannot-
be-accessed-in-macro-generated-class
Don’t forget the {}!
Real incremental recompilation
Let’s dive
Grab the Cat
TypeTag not accessible in a macro!
Wash the Cat
Inception matcher
Builder pattern
Matcher methods
// CatMatcher
Inception matcher
Cat matcher
Internal state
Inception matcher
new constraint =>
new matcher function
name/age/kitten methods
list of c.Expr[_]
Mirror, mirror
structural type =>
reflection :-(
// age
// matchA[Cat].age(6)
// Int
Yo, I heard you like macros
No structural type!
Yo, I heard you like macros
Annotation code
// @fieldMatcherBody(expected => cat.age must_== expected)
// val expected = 6
// cat.age must_== expected
Yo, I heard you like macros
extract parameter/body
Transformers
// 6
// `prefix` represents an equivalent of
// `this` for normal instance methods
// body:
// CatMatcher.this.addMatcher((_:Cat).age must_== arg)
Transformers
http://stackoverflow.com/questions/18523871/use-this-in-a-
generated-macro-method
Transformers -Yrangepos
Can you do this?
YES !!!
Thank you!
If you followed that far…

More Related Content

KEY
Cucaruba!
PDF
How would you describe Swift in three words?
KEY
Reusable View Components in Rails
PDF
Catch and Throw in Ruby
PPTX
Valentines Day
PPTX
Valentine's Day!
PPTX
St valentine´s day
PPT
Valentine's Day
Cucaruba!
How would you describe Swift in three words?
Reusable View Components in Rails
Catch and Throw in Ruby
Valentines Day
Valentine's Day!
St valentine´s day
Valentine's Day

More from Eric Torreborre (20)

PDF
Shoehorning dependency injection into a FP language
PDF
Shoehorning dependency injection into a FP language, what does it take?
PDF
Boost your command line applications with potions!
PDF
wire-all-the-things-lambda-days-2023.pdf
PDF
The many faces of modularity
PDF
What haskell taught us when we were not looking
PDF
Wire once, rewire twice! (Haskell exchange-2018)
PDF
Pratical eff-functional-conf
PDF
Specs2, from starters to dessert and... a look in the kitchen
PDF
Streaming, effects and beautiful folds: a winning trilogy
PPTX
Pratical eff-scalaitaly-2017
PDF
Pratical eff monad at Scaladays Chicago
PDF
Pratical eff
PPT
The Eff monad, one monad to rule them all
PPT
Easy di-slideshare
PPT
Data generation, the hard parts
PPT
Origami, a monadic fold library for Scala
PPT
Datatypes for the real world
PPT
Specs2 3.4
PPTX
DSLs with fold algebras
Shoehorning dependency injection into a FP language
Shoehorning dependency injection into a FP language, what does it take?
Boost your command line applications with potions!
wire-all-the-things-lambda-days-2023.pdf
The many faces of modularity
What haskell taught us when we were not looking
Wire once, rewire twice! (Haskell exchange-2018)
Pratical eff-functional-conf
Specs2, from starters to dessert and... a look in the kitchen
Streaming, effects and beautiful folds: a winning trilogy
Pratical eff-scalaitaly-2017
Pratical eff monad at Scaladays Chicago
Pratical eff
The Eff monad, one monad to rule them all
Easy di-slideshare
Data generation, the hard parts
Origami, a monadic fold library for Scala
Datatypes for the real world
Specs2 3.4
DSLs with fold algebras
Ad

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Approach and Philosophy of On baking technology
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Encapsulation theory and applications.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Approach and Philosophy of On baking technology
Group 1 Presentation -Planning and Decision Making .pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Encapsulation theory and applications.pdf
Machine Learning_overview_presentation.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation_ Review paper, used for researhc scholars
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Advanced methodologies resolving dimensionality complications for autism neur...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
“AI and Expert System Decision Support & Business Intelligence Systems”
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Ad

Vampire methods