SlideShare a Scribd company logo
Asynctweeter :: @RobertWPearce
github :: rpearce
email :: me@robertwpearce.com
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 1
about me
Hi, I'm Robert
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
about me
Hi, I'm Robert
• My kiwi wife & I have just moved back from New Zealand
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
about me
Hi, I'm Robert
• My kiwi wife & I have just moved back from New Zealand
• Started out at Jack Russell Software w/ Tom Wilson in 2011
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
about me
Hi, I'm Robert
• My kiwi wife & I have just moved back from New Zealand
• Started out at Jack Russell Software w/ Tom Wilson in 2011
• Currently with Articulate, the e-learning software company
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
about me
Hi, I'm Robert
• My kiwi wife & I have just moved back from New Zealand
• Started out at Jack Russell Software w/ Tom Wilson in 2011
• Currently with Articulate, the e-learning software company
• Work with FP in JS all day
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
about me
Hi, I'm Robert
• My kiwi wife & I have just moved back from New Zealand
• Started out at Jack Russell Software w/ Tom Wilson in 2011
• Currently with Articulate, the e-learning software company
• Work with FP in JS all day
• Learn Haskell (λ) in my free time
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
about me
Hi, I'm Robert
• My kiwi wife & I have just moved back from New Zealand
• Started out at Jack Russell Software w/ Tom Wilson in 2011
• Currently with Articulate, the e-learning software company
• Work with FP in JS all day
• Learn Haskell (λ) in my free time
• Pretend to know what I'm doing
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
Question:
what are we going to do?
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 3
Answer:
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 4
Answer:
• read & transform files with Promises
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 4
Answer:
• read & transform files with Promises
•
!
but with Asyncs
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 4
Answer:
• read & transform files with Promises
•
!
but with Asyncs
• ...this is our Friday night
✨
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 4
Use case?
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
Use case?
• reactjs component library monorepo
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
Use case?
• reactjs component library monorepo
• make it easy to bootstrap a new package
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
Use case?
• reactjs component library monorepo
• make it easy to bootstrap a new package
• solution:
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
Use case?
• reactjs component library monorepo
• make it easy to bootstrap a new package
• solution:
1. make templates
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
Use case?
• reactjs component library monorepo
• make it easy to bootstrap a new package
• solution:
1. make templates
2. make CLI app to collect options
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
Use case?
• reactjs component library monorepo
• make it easy to bootstrap a new package
• solution:
1. make templates
2. make CLI app to collect options
3. replace dummy template bits with options
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
refresher: fs.readFile
import fs from 'fs'
fs.readFile('/path/to/file', 'utf8', (err, contents) => {
if (err) {
throw err
}
console.log(contents)
})
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
refresher: fs.readFile
import fs from 'fs'
fs.readFile('/path/to/file', 'utf8', (err, contents) => {
if (err) {
throw err
}
console.log(contents)
})
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
refresher: fs.readFile
import fs from 'fs'
fs.readFile('/path/to/file', 'utf8', (err, contents) => {
if (err) {
throw err
}
console.log(contents)
})
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
refresher: fs.readFile
import fs from 'fs'
fs.readFile('/path/to/file', 'utf8', (err, contents) => {
if (err) {
throw err
}
console.log(contents)
})
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
refresher: fs.readFile
import fs from 'fs'
fs.readFile('/path/to/file', 'utf8', (err, contents) => {
if (err) {
throw err
}
console.log(contents)
})
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
refresher: fs.readFile
import fs from 'fs'
fs.readFile('/path/to/file', 'utf8', (err, contents) => {
if (err) {
throw err
}
console.log(contents)
})
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
refresher: fs.promises.readFile
import fs, { promises as fsp } from 'fs'
fsp
.readFile('/path/to/file', 'utf8')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
refresher: fs.promises.readFile
import fs, { promises as fsp } from 'fs'
fsp
.readFile('/path/to/file', 'utf8')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
refresher: fs.promises.readFile
import fs, { promises as fsp } from 'fs'
fsp
.readFile('/path/to/file', 'utf8')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
refresher: fs.promises.readFile
import fs, { promises as fsp } from 'fs'
fsp
.readFile('/path/to/file', 'utf8')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
refresher: fs.promises.readFile
import fs, { promises as fsp } from 'fs'
fsp
.readFile('/path/to/file', 'utf8')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
refresher: fs.promises.readFile
import fs, { promises as fsp } from 'fs'
fsp
.readFile('/path/to/file', 'utf8')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
refresher: async/await
import fs, { promises as fsp } from 'fs'
const toUpper = x => x.toUpperCase()
const readFileAndTransform = async (fn, f) => {
const contents = await fsp.readFile(f, 'utf8')
return fn(contents)
}
readFileAndTransform(toUpper, '/path/to/file')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
refresher: async/await
import fs, { promises as fsp } from 'fs'
const toUpper = x => x.toUpperCase()
const readFileAndTransform = async (fn, f) => {
const contents = await fsp.readFile(f, 'utf8')
return fn(contents)
}
readFileAndTransform(toUpper, '/path/to/file')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
refresher: async/await
import fs, { promises as fsp } from 'fs'
const toUpper = x => x.toUpperCase()
const readFileAndTransform = async (fn, f) => {
const contents = await fsp.readFile(f, 'utf8')
return fn(contents)
}
readFileAndTransform(toUpper, '/path/to/file')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
refresher: async/await
import fs, { promises as fsp } from 'fs'
const toUpper = x => x.toUpperCase()
const readFileAndTransform = async (fn, f) => {
const contents = await fsp.readFile(f, 'utf8')
return fn(contents)
}
readFileAndTransform(toUpper, '/path/to/file')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
refresher: async/await
import fs, { promises as fsp } from 'fs'
const toUpper = x => x.toUpperCase()
const readFileAndTransform = async (fn, f) => {
const contents = await fsp.readFile(f, 'utf8')
return fn(contents)
}
readFileAndTransform(toUpper, '/path/to/file')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
refresher: async/await
import fs, { promises as fsp } from 'fs'
const toUpper = x => x.toUpperCase()
const readFileAndTransform = async (fn, f) => {
const contents = await fsp.readFile(f, 'utf8')
return fn(contents)
}
readFileAndTransform(toUpper, '/path/to/file')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
refresher: async/await
import fs, { promises as fsp } from 'fs'
const toUpper = x => x.toUpperCase()
const readFileAndTransform = async (fn, f) => {
const contents = await fsp.readFile(f, 'utf8')
return fn(contents)
}
readFileAndTransform(toUpper, '/path/to/file')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
refresher: async/await
import fs, { promises as fsp } from 'fs'
const toUpper = x => x.toUpperCase()
const readFileAndTransform = async (fn, f) => {
const contents = await fsp.readFile(f, 'utf8')
return fn(contents)
}
readFileAndTransform(toUpper, '/path/to/file')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
refresher: async/await
import fs, { promises as fsp } from 'fs'
const toUpper = x => x.toUpperCase()
const readFileAndTransform = async (fn, f) => {
const contents = await fsp.readFile(f, 'utf8')
return fn(contents)
}
readFileAndTransform(toUpper, '/path/to/file')
.then(console.log)
.catch(console.error)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
drawbacks with callbacks
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
drawbacks with callbacks
• asynchronous callbacks (like in fs.readFile) don't return a
value to caller
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
drawbacks with callbacks
• asynchronous callbacks (like in fs.readFile) don't return a
value to caller
• (not composable...easily)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
drawbacks with callbacks
• asynchronous callbacks (like in fs.readFile) don't return a
value to caller
• (not composable...easily)
• don't work well with control flow (if (fs.readFile(...)))
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
drawbacks with callbacks
• asynchronous callbacks (like in fs.readFile) don't return a
value to caller
• (not composable...easily)
• don't work well with control flow (if (fs.readFile(...)))
• inevitably nest ---->
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 10
Callbacks are the narrowing spiral
staircase to hell. They are control
flow as designed by M.C. Escher.
— Dr. Boolean, Professor Frisby's Mostly Adequate Guide to
Functional Programming
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 11
Promises are awesome! But...
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
Promises are awesome! But...
• values; not computations (like a function or other structure)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
Promises are awesome! But...
• values; not computations (like a function or other structure)
• don't support cancellation
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
Promises are awesome! But...
• values; not computations (like a function or other structure)
• don't support cancellation
• don't support nesting
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
Promises are awesome! But...
• values; not computations (like a function or other structure)
• don't support cancellation
• don't support nesting
• impure
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
!
might not phase you at all
i still ❤ callbacks & promises
but let's see a different tool!
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 13
break out neovim & friends
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 14
what exactly is an Async (aka Task)?
• "lazy Sum Type that implements an asynchronous control
structure"
• will not execute until needed
• keeps track of its internals (
!
for cleanup & cancellation)
Async e a = Rejected e | Resolved a
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 15
example in the wild wrapping the axios library
https://github.com/articulate/asyncios
// POST request
asyncios({
method: 'POST',
url: '/user?ID=12345',
data: { firstName: 'Fred', lastName: 'Flinstone' },
})
.fork(
error => console.log(error),
response => console.log(response)
)
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 16
what is crocks?
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 17
what is ramda?
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 18
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 19
where can i learn more?
• https://crocks.dev/docs/crocks/Async.html
• https://gitter.im/crocksjs/crocks
• TheEvilSoft's youtube channel
• Professor Frisby's Mostly Adequate Guide to Functional Programming
• https://folktale.origamitower.com/api/v2.3.0/en/
folktale.concurrency.task.html
• Functional Programming in JavaScript with Ramda.js
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 20
Asynctweeter :: @RobertWPearce
github :: rpearce
email :: me@robertwpearce.com
@RobertWPearce | rwp.im | 2019-08-23 charleston.js 21

More Related Content

What's hot

GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control System
Tommaso Visconti
 
Git inter-snapshot public
Git  inter-snapshot publicGit  inter-snapshot public
Git inter-snapshot public
SeongJae Park
 
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
Rotzy - Building an iPhone Photo Sharing App on Google App EngineRotzy - Building an iPhone Photo Sharing App on Google App Engine
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
geehwan
 
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
Puppet
 
DO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCSDO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCS
SeongJae Park
 
성장을 좋아하는 사람이, 성장하고 싶은 사람에게
성장을 좋아하는 사람이, 성장하고 싶은 사람에게성장을 좋아하는 사람이, 성장하고 싶은 사람에게
성장을 좋아하는 사람이, 성장하고 싶은 사람에게
Seongyun Byeon
 
Version Control and Git - GitHub Workshop
Version Control and Git - GitHub WorkshopVersion Control and Git - GitHub Workshop
Version Control and Git - GitHub Workshop
All Things Open
 
Node Tools For Your Grails Toolbox - Gr8Conf 2013
Node Tools For Your Grails Toolbox - Gr8Conf 2013Node Tools For Your Grails Toolbox - Gr8Conf 2013
Node Tools For Your Grails Toolbox - Gr8Conf 2013
zanthrash
 
Practical unix utilities for text processing
Practical unix utilities for text processingPractical unix utilities for text processing
Practical unix utilities for text processingAnton Arhipov
 

What's hot (9)

GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control System
 
Git inter-snapshot public
Git  inter-snapshot publicGit  inter-snapshot public
Git inter-snapshot public
 
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
Rotzy - Building an iPhone Photo Sharing App on Google App EngineRotzy - Building an iPhone Photo Sharing App on Google App Engine
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
 
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
 
DO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCSDO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCS
 
성장을 좋아하는 사람이, 성장하고 싶은 사람에게
성장을 좋아하는 사람이, 성장하고 싶은 사람에게성장을 좋아하는 사람이, 성장하고 싶은 사람에게
성장을 좋아하는 사람이, 성장하고 싶은 사람에게
 
Version Control and Git - GitHub Workshop
Version Control and Git - GitHub WorkshopVersion Control and Git - GitHub Workshop
Version Control and Git - GitHub Workshop
 
Node Tools For Your Grails Toolbox - Gr8Conf 2013
Node Tools For Your Grails Toolbox - Gr8Conf 2013Node Tools For Your Grails Toolbox - Gr8Conf 2013
Node Tools For Your Grails Toolbox - Gr8Conf 2013
 
Practical unix utilities for text processing
Practical unix utilities for text processingPractical unix utilities for text processing
Practical unix utilities for text processing
 

Similar to From Promises & async/await to Async Algebraic Data Types

ReactPHP
ReactPHPReactPHP
ReactPHP
Philip Norton
 
SOOCon24 - Showing that you care about security - OpenSSF Scorecards
SOOCon24 - Showing that you care about security - OpenSSF ScorecardsSOOCon24 - Showing that you care about security - OpenSSF Scorecards
SOOCon24 - Showing that you care about security - OpenSSF Scorecards
Chris Swan
 
Genomics Is Not Special: Towards Data Intensive Biology
Genomics Is Not Special: Towards Data Intensive BiologyGenomics Is Not Special: Towards Data Intensive Biology
Genomics Is Not Special: Towards Data Intensive Biology
Uri Laserson
 
Advanced I/O in browser
Advanced I/O in browserAdvanced I/O in browser
Advanced I/O in browser
Eugene Lazutkin
 
React, Powered by WebAssembly
React, Powered by WebAssemblyReact, Powered by WebAssembly
React, Powered by WebAssembly
Jay Phelps
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from Data
Mosky Liu
 
It’s about time to embrace Streams
It’s about time to embrace StreamsIt’s about time to embrace Streams
It’s about time to embrace Streams
Luciano Mammino
 
Downloading a Billion Files in Python
Downloading a Billion Files in PythonDownloading a Billion Files in Python
Downloading a Billion Files in Python
James Saryerwinnie
 
Filesystems Lisbon 2018
Filesystems Lisbon 2018Filesystems Lisbon 2018
Filesystems Lisbon 2018
Frank de Jonge
 
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
CODE BLUE
 
Unix command-line tools
Unix command-line toolsUnix command-line tools
Unix command-line toolsEric Wilson
 
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAwesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Ajeet Singh Raina
 
Writing and using php streams and sockets tek11
Writing and using php streams and sockets   tek11Writing and using php streams and sockets   tek11
Writing and using php streams and sockets tek11
Elizabeth Smith
 
Sprockets
SprocketsSprockets
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
Motaz Saad
 
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...
Samuel Lampa
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaLin Yo-An
 
lwref: insane idea on reference counting
lwref: insane idea on reference countinglwref: insane idea on reference counting
lwref: insane idea on reference counting
Gleb Smirnoff
 
CPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its toolsCPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its tools
charsbar
 

Similar to From Promises & async/await to Async Algebraic Data Types (20)

ReactPHP
ReactPHPReactPHP
ReactPHP
 
SOOCon24 - Showing that you care about security - OpenSSF Scorecards
SOOCon24 - Showing that you care about security - OpenSSF ScorecardsSOOCon24 - Showing that you care about security - OpenSSF Scorecards
SOOCon24 - Showing that you care about security - OpenSSF Scorecards
 
Genomics Is Not Special: Towards Data Intensive Biology
Genomics Is Not Special: Towards Data Intensive BiologyGenomics Is Not Special: Towards Data Intensive Biology
Genomics Is Not Special: Towards Data Intensive Biology
 
Advanced I/O in browser
Advanced I/O in browserAdvanced I/O in browser
Advanced I/O in browser
 
React, Powered by WebAssembly
React, Powered by WebAssemblyReact, Powered by WebAssembly
React, Powered by WebAssembly
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from Data
 
It’s about time to embrace Streams
It’s about time to embrace StreamsIt’s about time to embrace Streams
It’s about time to embrace Streams
 
Downloading a Billion Files in Python
Downloading a Billion Files in PythonDownloading a Billion Files in Python
Downloading a Billion Files in Python
 
Filesystems Lisbon 2018
Filesystems Lisbon 2018Filesystems Lisbon 2018
Filesystems Lisbon 2018
 
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
 
Unix command-line tools
Unix command-line toolsUnix command-line tools
Unix command-line tools
 
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAwesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
 
Writing and using php streams and sockets tek11
Writing and using php streams and sockets   tek11Writing and using php streams and sockets   tek11
Writing and using php streams and sockets tek11
 
Sprockets
SprocketsSprockets
Sprockets
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
Os Treat
Os TreatOs Treat
Os Treat
 
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
lwref: insane idea on reference counting
lwref: insane idea on reference countinglwref: insane idea on reference counting
lwref: insane idea on reference counting
 
CPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its toolsCPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its tools
 

More from Robert Pearce

How to Lose Functional Programming at Work
How to Lose Functional Programming at WorkHow to Lose Functional Programming at Work
How to Lose Functional Programming at Work
Robert Pearce
 
hakyll – haskell static site generator
hakyll – haskell static site generatorhakyll – haskell static site generator
hakyll – haskell static site generator
Robert Pearce
 
Behaviour & Your Team
Behaviour & Your TeamBehaviour & Your Team
Behaviour & Your Team
Robert Pearce
 
Static sites with react
Static sites with reactStatic sites with react
Static sites with react
Robert Pearce
 
React.js Basics - ConvergeSE 2015
React.js Basics - ConvergeSE 2015React.js Basics - ConvergeSE 2015
React.js Basics - ConvergeSE 2015
Robert Pearce
 
JavaScript 101 - Class 2
JavaScript 101 - Class 2JavaScript 101 - Class 2
JavaScript 101 - Class 2
Robert Pearce
 
JavaScript 101 - Class 1
JavaScript 101 - Class 1JavaScript 101 - Class 1
JavaScript 101 - Class 1
Robert Pearce
 

More from Robert Pearce (7)

How to Lose Functional Programming at Work
How to Lose Functional Programming at WorkHow to Lose Functional Programming at Work
How to Lose Functional Programming at Work
 
hakyll – haskell static site generator
hakyll – haskell static site generatorhakyll – haskell static site generator
hakyll – haskell static site generator
 
Behaviour & Your Team
Behaviour & Your TeamBehaviour & Your Team
Behaviour & Your Team
 
Static sites with react
Static sites with reactStatic sites with react
Static sites with react
 
React.js Basics - ConvergeSE 2015
React.js Basics - ConvergeSE 2015React.js Basics - ConvergeSE 2015
React.js Basics - ConvergeSE 2015
 
JavaScript 101 - Class 2
JavaScript 101 - Class 2JavaScript 101 - Class 2
JavaScript 101 - Class 2
 
JavaScript 101 - Class 1
JavaScript 101 - Class 1JavaScript 101 - Class 1
JavaScript 101 - Class 1
 

Recently uploaded

E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 

Recently uploaded (20)

E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 

From Promises & async/await to Async Algebraic Data Types

  • 1. Asynctweeter :: @RobertWPearce github :: rpearce email :: me@robertwpearce.com @RobertWPearce | rwp.im | 2019-08-23 charleston.js 1
  • 2. about me Hi, I'm Robert @RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
  • 3. about me Hi, I'm Robert • My kiwi wife & I have just moved back from New Zealand @RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
  • 4. about me Hi, I'm Robert • My kiwi wife & I have just moved back from New Zealand • Started out at Jack Russell Software w/ Tom Wilson in 2011 @RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
  • 5. about me Hi, I'm Robert • My kiwi wife & I have just moved back from New Zealand • Started out at Jack Russell Software w/ Tom Wilson in 2011 • Currently with Articulate, the e-learning software company @RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
  • 6. about me Hi, I'm Robert • My kiwi wife & I have just moved back from New Zealand • Started out at Jack Russell Software w/ Tom Wilson in 2011 • Currently with Articulate, the e-learning software company • Work with FP in JS all day @RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
  • 7. about me Hi, I'm Robert • My kiwi wife & I have just moved back from New Zealand • Started out at Jack Russell Software w/ Tom Wilson in 2011 • Currently with Articulate, the e-learning software company • Work with FP in JS all day • Learn Haskell (λ) in my free time @RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
  • 8. about me Hi, I'm Robert • My kiwi wife & I have just moved back from New Zealand • Started out at Jack Russell Software w/ Tom Wilson in 2011 • Currently with Articulate, the e-learning software company • Work with FP in JS all day • Learn Haskell (λ) in my free time • Pretend to know what I'm doing @RobertWPearce | rwp.im | 2019-08-23 charleston.js 2
  • 9. Question: what are we going to do? @RobertWPearce | rwp.im | 2019-08-23 charleston.js 3
  • 10. Answer: @RobertWPearce | rwp.im | 2019-08-23 charleston.js 4
  • 11. Answer: • read & transform files with Promises @RobertWPearce | rwp.im | 2019-08-23 charleston.js 4
  • 12. Answer: • read & transform files with Promises • ! but with Asyncs @RobertWPearce | rwp.im | 2019-08-23 charleston.js 4
  • 13. Answer: • read & transform files with Promises • ! but with Asyncs • ...this is our Friday night ✨ @RobertWPearce | rwp.im | 2019-08-23 charleston.js 4
  • 14. Use case? @RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
  • 15. Use case? • reactjs component library monorepo @RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
  • 16. Use case? • reactjs component library monorepo • make it easy to bootstrap a new package @RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
  • 17. Use case? • reactjs component library monorepo • make it easy to bootstrap a new package • solution: @RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
  • 18. Use case? • reactjs component library monorepo • make it easy to bootstrap a new package • solution: 1. make templates @RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
  • 19. Use case? • reactjs component library monorepo • make it easy to bootstrap a new package • solution: 1. make templates 2. make CLI app to collect options @RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
  • 20. Use case? • reactjs component library monorepo • make it easy to bootstrap a new package • solution: 1. make templates 2. make CLI app to collect options 3. replace dummy template bits with options @RobertWPearce | rwp.im | 2019-08-23 charleston.js 5
  • 21. refresher: fs.readFile import fs from 'fs' fs.readFile('/path/to/file', 'utf8', (err, contents) => { if (err) { throw err } console.log(contents) }) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
  • 22. refresher: fs.readFile import fs from 'fs' fs.readFile('/path/to/file', 'utf8', (err, contents) => { if (err) { throw err } console.log(contents) }) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
  • 23. refresher: fs.readFile import fs from 'fs' fs.readFile('/path/to/file', 'utf8', (err, contents) => { if (err) { throw err } console.log(contents) }) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
  • 24. refresher: fs.readFile import fs from 'fs' fs.readFile('/path/to/file', 'utf8', (err, contents) => { if (err) { throw err } console.log(contents) }) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
  • 25. refresher: fs.readFile import fs from 'fs' fs.readFile('/path/to/file', 'utf8', (err, contents) => { if (err) { throw err } console.log(contents) }) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
  • 26. refresher: fs.readFile import fs from 'fs' fs.readFile('/path/to/file', 'utf8', (err, contents) => { if (err) { throw err } console.log(contents) }) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 6
  • 27. refresher: fs.promises.readFile import fs, { promises as fsp } from 'fs' fsp .readFile('/path/to/file', 'utf8') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
  • 28. refresher: fs.promises.readFile import fs, { promises as fsp } from 'fs' fsp .readFile('/path/to/file', 'utf8') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
  • 29. refresher: fs.promises.readFile import fs, { promises as fsp } from 'fs' fsp .readFile('/path/to/file', 'utf8') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
  • 30. refresher: fs.promises.readFile import fs, { promises as fsp } from 'fs' fsp .readFile('/path/to/file', 'utf8') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
  • 31. refresher: fs.promises.readFile import fs, { promises as fsp } from 'fs' fsp .readFile('/path/to/file', 'utf8') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
  • 32. refresher: fs.promises.readFile import fs, { promises as fsp } from 'fs' fsp .readFile('/path/to/file', 'utf8') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 7
  • 33. refresher: async/await import fs, { promises as fsp } from 'fs' const toUpper = x => x.toUpperCase() const readFileAndTransform = async (fn, f) => { const contents = await fsp.readFile(f, 'utf8') return fn(contents) } readFileAndTransform(toUpper, '/path/to/file') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
  • 34. refresher: async/await import fs, { promises as fsp } from 'fs' const toUpper = x => x.toUpperCase() const readFileAndTransform = async (fn, f) => { const contents = await fsp.readFile(f, 'utf8') return fn(contents) } readFileAndTransform(toUpper, '/path/to/file') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
  • 35. refresher: async/await import fs, { promises as fsp } from 'fs' const toUpper = x => x.toUpperCase() const readFileAndTransform = async (fn, f) => { const contents = await fsp.readFile(f, 'utf8') return fn(contents) } readFileAndTransform(toUpper, '/path/to/file') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
  • 36. refresher: async/await import fs, { promises as fsp } from 'fs' const toUpper = x => x.toUpperCase() const readFileAndTransform = async (fn, f) => { const contents = await fsp.readFile(f, 'utf8') return fn(contents) } readFileAndTransform(toUpper, '/path/to/file') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
  • 37. refresher: async/await import fs, { promises as fsp } from 'fs' const toUpper = x => x.toUpperCase() const readFileAndTransform = async (fn, f) => { const contents = await fsp.readFile(f, 'utf8') return fn(contents) } readFileAndTransform(toUpper, '/path/to/file') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
  • 38. refresher: async/await import fs, { promises as fsp } from 'fs' const toUpper = x => x.toUpperCase() const readFileAndTransform = async (fn, f) => { const contents = await fsp.readFile(f, 'utf8') return fn(contents) } readFileAndTransform(toUpper, '/path/to/file') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
  • 39. refresher: async/await import fs, { promises as fsp } from 'fs' const toUpper = x => x.toUpperCase() const readFileAndTransform = async (fn, f) => { const contents = await fsp.readFile(f, 'utf8') return fn(contents) } readFileAndTransform(toUpper, '/path/to/file') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
  • 40. refresher: async/await import fs, { promises as fsp } from 'fs' const toUpper = x => x.toUpperCase() const readFileAndTransform = async (fn, f) => { const contents = await fsp.readFile(f, 'utf8') return fn(contents) } readFileAndTransform(toUpper, '/path/to/file') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
  • 41. refresher: async/await import fs, { promises as fsp } from 'fs' const toUpper = x => x.toUpperCase() const readFileAndTransform = async (fn, f) => { const contents = await fsp.readFile(f, 'utf8') return fn(contents) } readFileAndTransform(toUpper, '/path/to/file') .then(console.log) .catch(console.error) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 8
  • 42. drawbacks with callbacks @RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
  • 43. drawbacks with callbacks • asynchronous callbacks (like in fs.readFile) don't return a value to caller @RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
  • 44. drawbacks with callbacks • asynchronous callbacks (like in fs.readFile) don't return a value to caller • (not composable...easily) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
  • 45. drawbacks with callbacks • asynchronous callbacks (like in fs.readFile) don't return a value to caller • (not composable...easily) • don't work well with control flow (if (fs.readFile(...))) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
  • 46. drawbacks with callbacks • asynchronous callbacks (like in fs.readFile) don't return a value to caller • (not composable...easily) • don't work well with control flow (if (fs.readFile(...))) • inevitably nest ----> @RobertWPearce | rwp.im | 2019-08-23 charleston.js 9
  • 47. @RobertWPearce | rwp.im | 2019-08-23 charleston.js 10
  • 48. Callbacks are the narrowing spiral staircase to hell. They are control flow as designed by M.C. Escher. — Dr. Boolean, Professor Frisby's Mostly Adequate Guide to Functional Programming @RobertWPearce | rwp.im | 2019-08-23 charleston.js 11
  • 49. Promises are awesome! But... @RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
  • 50. Promises are awesome! But... • values; not computations (like a function or other structure) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
  • 51. Promises are awesome! But... • values; not computations (like a function or other structure) • don't support cancellation @RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
  • 52. Promises are awesome! But... • values; not computations (like a function or other structure) • don't support cancellation • don't support nesting @RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
  • 53. Promises are awesome! But... • values; not computations (like a function or other structure) • don't support cancellation • don't support nesting • impure @RobertWPearce | rwp.im | 2019-08-23 charleston.js 12
  • 54. ! might not phase you at all i still ❤ callbacks & promises but let's see a different tool! @RobertWPearce | rwp.im | 2019-08-23 charleston.js 13
  • 55. break out neovim & friends @RobertWPearce | rwp.im | 2019-08-23 charleston.js 14
  • 56. what exactly is an Async (aka Task)? • "lazy Sum Type that implements an asynchronous control structure" • will not execute until needed • keeps track of its internals ( ! for cleanup & cancellation) Async e a = Rejected e | Resolved a @RobertWPearce | rwp.im | 2019-08-23 charleston.js 15
  • 57. example in the wild wrapping the axios library https://github.com/articulate/asyncios // POST request asyncios({ method: 'POST', url: '/user?ID=12345', data: { firstName: 'Fred', lastName: 'Flinstone' }, }) .fork( error => console.log(error), response => console.log(response) ) @RobertWPearce | rwp.im | 2019-08-23 charleston.js 16
  • 58. what is crocks? @RobertWPearce | rwp.im | 2019-08-23 charleston.js 17
  • 59. what is ramda? @RobertWPearce | rwp.im | 2019-08-23 charleston.js 18
  • 60. @RobertWPearce | rwp.im | 2019-08-23 charleston.js 19
  • 61. where can i learn more? • https://crocks.dev/docs/crocks/Async.html • https://gitter.im/crocksjs/crocks • TheEvilSoft's youtube channel • Professor Frisby's Mostly Adequate Guide to Functional Programming • https://folktale.origamitower.com/api/v2.3.0/en/ folktale.concurrency.task.html • Functional Programming in JavaScript with Ramda.js @RobertWPearce | rwp.im | 2019-08-23 charleston.js 20
  • 62. Asynctweeter :: @RobertWPearce github :: rpearce email :: me@robertwpearce.com @RobertWPearce | rwp.im | 2019-08-23 charleston.js 21