Wire all the things!
Eric Torreborre
Encoders / decoders
for a data model
Generators
for a data model
A large application
A large application
What do they have in
common?
They form a graph
Each node in the
graph has a type
The graph is in
general acyclic
It is useful to modify the graph
• mock a component
• evolve the data model
• generate data differently
Encoders /
decoders
Protocol definition on the
blockchain
Immutable FTW
The only thing that doesn’t
change is change itself
New commands
Better protocols
Faster commands
Deprecated commands
etc…
What if we want to compress
the parameters in V2?
Transaction
Signer Metadata
Command
NewChannel … Execute
Contract Function Parameters
Bad idea: Data.Generics
Use a newtype?
Bad idea: Data.Generics
> ObjectArray [ObjectStr "stocks",ObjectInt 1]
> ObjectArray [
ObjectStr “stocks",
ObjectInt 1,
ObjectBool False
]
> ObjectArray [
ObjectArray [
ObjectStr “stocks",
ObjectInt 1
],
ObjectBool False,
ObjectStr “john"
]
Bad idea: Data.Generics
Back to manual instances?
Better idea: manually
Manually: wiring
Manually: compressed
parameters
Can we make it easier?
function application
everywhere!
Better! Compact and
incremental definitions
functions in a list
automated
function application
TH to the rescue
Compressed parameters
incremental definition
Data
generation
Data generation
Bad idea: typeclasses
Applicative = fun
But what happens when
there’s a new field?
Bad idea: typeclasses
I want transactions with no SendKey
I want to force the contract version to be 2
I want distinct Signers
etc…
Better idea: manually
Ok, but can we make it easier?
Let’s extend the data model
let’s add a Maybe
and a list
Using registry-hedgehog
TH for the boilerplate
I want transactions with no SendKey
Super powers
I want transactions with no SendKey
Super powers
I want to force the contract version to be 2
Super powers
I want to force the contract version to be 2
Super powers
Special care needs to be taken for recursive values!
(see registry-hedgehog-aeson)
Recursive data types
Applications
Application
FrontEnd
Transaction
Processor
Event
Listener
ValueStore
Sql Logger Tracer
Http
Cryptography
Applications
Bad idea: use typeclasses
classes define interfaces
instances define
implementations
constraints define
dependencies
And
GHC does
the
magic
Bad idea n.2: use an effect library
tedious, hard to navigate…
Reify all operations
(from https://github.com/hasura/eff)
Need to know about: Algebra, Carrier,
type level operations etc…
Write interpreters
(from https://github.com/fused-effects/fused-effects)
Bad idea n.2: use an effect library
(from https://github.com/thma/PolysemyCleanArchitecture)
How to replace just `runInputConst`?
Stack interpreters
For a more in-depth review: https://abailly.github.io/slides/heureux-les-simples.html
Bad idea n.2: use an effect library
Bad idea n.3: ReaderT
Application
FrontEnd
Transaction
Processor
Event
Listener
ValueStore
Sql Logger Tracer
Http
Cryptography
Better idea: manually
Define components
record of functions ~
interface
dependencies ~ parameters
constructor function ~
implementation
Manually: wiring
Simpler than effects but
still hard to wire / rewire
Using a registry
Profit!
Modify dependencies
No other change required!
Profit!
Inject mocks for testing
Changes are composable g
f
Profit!
Select the configuration at start-up
We can make that code very declarative and flexible
Profit!
Display the graph
Where’s the catch?
YOU DON’T HAVE TO USE
TYPECLASSES TO WIRE YOUR CODE.
YOU JUST CREATE FUNCTIONS
AND PUT THEM IN A REGISTRY. THEN
YOU INVOKE THE INSTANCE YOU
NEED BY PASSING ITS TYPE. AND IF
YOU WANT TO INJECT ANOTHER
INSTANCE ITS EASY YOU CAN JUST
PUT ANOTHER FUNCTION ON TOP OF
THE LIST. YOU CAN EVEN ADD IT
ONLY TO A SUB PART OF THE GRAPH.
YOU LEARN THIS TECHNIQUE ONCE
AND APPLY IT TO MANY CONTEXTS:
APPLICATION WIRING, ENCODERS /
DECODERS, DATA GENERATION.
MOST MODIFICATIONS ARE LOCAL
AND YOU DON’T HAVE TO CHANGE
THE WIRING CODE, WHICH MAKES IT
IDEAL FOR MAINTENANCE. ON GITH
Type errors
forget a dependency
Type errors
add a polymorphic function
Type errors
forget to use ‘add’
Compilation times
type-level sets
ReaderT IO to bind them all
Thank you!
(And wire all the things with
https://github.com/etorreborre/registry…)

More Related Content

PPTX
Sharding Methods for MongoDB
PDF
Producer Performance Tuning for Apache Kafka
PPTX
Hive + Tez: A Performance Deep Dive
PPTX
Introduction to Storm
PDF
MongoDB WiredTiger Internals
PPTX
Solr introduction
PPTX
Apache Kafka 0.8 basic training - Verisign
PDF
Indexing
Sharding Methods for MongoDB
Producer Performance Tuning for Apache Kafka
Hive + Tez: A Performance Deep Dive
Introduction to Storm
MongoDB WiredTiger Internals
Solr introduction
Apache Kafka 0.8 basic training - Verisign
Indexing

What's hot (20)

PDF
Quick introduction to scala
PDF
What to do if Your Kafka Streams App Gets OOMKilled? with Andrey Serebryanskiy
PPTX
The Current State of Table API in 2022
PDF
Spark SQL Deep Dive @ Melbourne Spark Meetup
PDF
Hive Anatomy
PPTX
Apache Tez – Present and Future
PPTX
Kafka Retry and DLQ
PPTX
Building Reliable Lakehouses with Apache Flink and Delta Lake
PPTX
Performance Optimizations in Apache Impala
PPTX
Kafka Streams for Java enthusiasts
PPTX
An Enterprise Architect's View of MongoDB
PDF
Cassandra Introduction & Features
PDF
Unify Stream and Batch Processing using Dataflow, a Portable Programmable Mod...
PDF
InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...
PDF
SQL for NoSQL and how Apache Calcite can help
PDF
Introduction to Apache Kafka
PDF
Monitoring Hadoop with Prometheus (Hadoop User Group Ireland, December 2015)
PDF
Intro to HBase
PPTX
Introduction to Scala
Quick introduction to scala
What to do if Your Kafka Streams App Gets OOMKilled? with Andrey Serebryanskiy
The Current State of Table API in 2022
Spark SQL Deep Dive @ Melbourne Spark Meetup
Hive Anatomy
Apache Tez – Present and Future
Kafka Retry and DLQ
Building Reliable Lakehouses with Apache Flink and Delta Lake
Performance Optimizations in Apache Impala
Kafka Streams for Java enthusiasts
An Enterprise Architect's View of MongoDB
Cassandra Introduction & Features
Unify Stream and Batch Processing using Dataflow, a Portable Programmable Mod...
InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...
SQL for NoSQL and how Apache Calcite can help
Introduction to Apache Kafka
Monitoring Hadoop with Prometheus (Hadoop User Group Ireland, December 2015)
Intro to HBase
Introduction to Scala
Ad

Similar to wire-all-the-things-lambda-days-2023.pdf (20)

KEY
Adventures building 3 realtime single-page apps 6 different ways
PPTX
ISI work
ODP
Sysprog 10
ODP
Sysprog 10
ODP
Can't Dance The Lambda
PDF
Advanced web application architecture - Talk
PDF
Hexagonal Symfony - SymfonyCon Amsterdam 2019
PPTX
Microservices Part 4: Functional Reactive Programming
PPT
Hatkit Project - Datafiddler
PDF
Python master class 2
PDF
Android application architecture
PPTX
Dynamic Language Performance
PDF
NoSQLEU: Different NoSQL tools in Production
PDF
x86 Software Reverse-Engineering, Cracking, and Counter-Measures 1st Edition ...
ODP
newerahpc grid
PDF
Advanced web application architecture - PHP Barcelona
PDF
Web Development with Smalltalk
PPT
Generalized Functors - Realizing Command Design Pattern in C++
PPT
A Practical Event Driven Model
PDF
Nt1310 Unit 3 Language Analysis
Adventures building 3 realtime single-page apps 6 different ways
ISI work
Sysprog 10
Sysprog 10
Can't Dance The Lambda
Advanced web application architecture - Talk
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Microservices Part 4: Functional Reactive Programming
Hatkit Project - Datafiddler
Python master class 2
Android application architecture
Dynamic Language Performance
NoSQLEU: Different NoSQL tools in Production
x86 Software Reverse-Engineering, Cracking, and Counter-Measures 1st Edition ...
newerahpc grid
Advanced web application architecture - PHP Barcelona
Web Development with Smalltalk
Generalized Functors - Realizing Command Design Pattern in C++
A Practical Event Driven Model
Nt1310 Unit 3 Language Analysis
Ad

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
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
PPT
Specs2 whirlwind tour at Scaladays 2014
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!
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
Specs2 whirlwind tour at Scaladays 2014

Recently uploaded (20)

PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PPTX
2018-HIPAA-Renewal-Training for executives
PPTX
The various Industrial Revolutions .pptx
PPT
Geologic Time for studying geology for geologist
PDF
Five Habits of High-Impact Board Members
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
STKI Israel Market Study 2025 version august
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
Configure Apache Mutual Authentication
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
CloudStack 4.21: First Look Webinar slides
Flame analysis and combustion estimation using large language and vision assi...
Convolutional neural network based encoder-decoder for efficient real-time ob...
2018-HIPAA-Renewal-Training for executives
The various Industrial Revolutions .pptx
Geologic Time for studying geology for geologist
Five Habits of High-Impact Board Members
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
STKI Israel Market Study 2025 version august
A proposed approach for plagiarism detection in Myanmar Unicode text
Configure Apache Mutual Authentication
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Final SEM Unit 1 for mit wpu at pune .pptx
A comparative study of natural language inference in Swahili using monolingua...
OpenACC and Open Hackathons Monthly Highlights July 2025
UiPath Agentic Automation session 1: RPA to Agents
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
Benefits of Physical activity for teenagers.pptx
A review of recent deep learning applications in wood surface defect identifi...
CloudStack 4.21: First Look Webinar slides

wire-all-the-things-lambda-days-2023.pdf