Skip to content

Instantly share code, notes, and snippets.

@hasparus
Last active December 18, 2019 15:40
Show Gist options
  • Save hasparus/41517c476d175012235cb28916f09490 to your computer and use it in GitHub Desktop.
Save hasparus/41517c476d175012235cb28916f09490 to your computer and use it in GitHub Desktop.
  1. Yo I'm Piotr
  2. I'm working at Chop-Chop. We're recruiting. I'll get some money for bringing you in.
  3. 3 things I wanna sell tonight
    1. Follow me on Twitter
    2. Option has problems
    3. Write your own instances

Yo I'm Piotr Monwid-Olechnowicz. I'm working at Chop-Chop; We're recruiting so if you wanna do cool shit with TypeScript and React talk to me, and if you're good, I'll get some money for bringing you in. Win-win, right?

I'm gonna be boring and start with an agenda.

There are 3 things I wanna sell tonight.

  1. Myself, obviously. You should follow me on Twitter. I retweet dank memes and occasionally post smart stuff about TypeScript.

  2. Option from fp-ts and similar abstractions have two big problems and few small ones. We'll get to them shortly.

  3. Writing your own instances of fp-ts typeclasses is super easy. Don't be afraid to write your own. The best thing about it -- You get to import tests from a library.

    https://en.wikipedia.org/wiki/Principle_of_least_astonishment

    Why should you consider it? Building on known abstractions makes your code less surprising. Don't reinvent the wheel.

Let us continue. Three quick questions.

  1. Who's using fp-ts and Option in particular?
  2. Who knows who Rich Hickey is?
  3. And who has seen his "Maybe Not" talk from Clojure Conj(oin) 2018?

So you won't notice that I've stolen slides from him. Awesome.

This is the Option. Can you see these interfaces? We wrap our some A into an object and None is now truthy, because it's an object oo. This is a small thing, but I'd like to think that we deserve better.

And we can't use the new fancy syntax we have in TypeScript -- nullish coallescence and optional chaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment