~/talk

Monoidal Identity Elements, or, How to pick a default argument value

Talkat UtahJS Conf 2019 · on Friday, 2019-09-20· [javascript, compilers-and-language-design]
links:none on file
slides:none on file

Argues that default argument values should be the monoidal identity for the type so guards and undefined checks disappear; shows identity function and compose via live coding to make functions a monoid, and lists the eight basic JavaScript monoids (numbers: + → 0, * → 1; string → "", array → [], object → {}; boolean AND → true, OR → false). Uses plain JS plus lodash/ramda identity utilities and demonstrates cleaner, self-documenting code that actually reduces boilerplate.

AI-written summary · about

  1. 0:00Introduction and welcome
  2. 1:24JavaScript default values
  3. 3:36What is a monoidal identity element
  4. 4:38Monoids explained simply
  5. 7:04Number monoids in JavaScript
  6. 8:28String monoids in JavaScript
  7. 9:10Boolean monoids in JavaScript
  8. 10:37Array monoids in JavaScript
  9. 11:43Object monoids in JavaScript
  10. 13:08Function monoids introduction
  11. 14:44Discovering function operator
  12. 16:54Function composition as operator
  13. 19:07Identity function for monoids
  14. 20:57Default values with monoids
  15. 22:04Code example comparison
  16. 23:34Benefits of monoids in code
  17. 24:36Summary and takeaways
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.