Robin Pokorny
1 min readAug 13, 2021

--

Hey Michael,

Regarding the first part, I think, the fundamental problem is that the code is supposed to be a library which should accept any value. This value has a meaning for the library user. It can also be a `null` or `undefined`, in fact, I expect that since that is the usual way of dealing with a missing value.

I could wrap this value in an object and treat `null` as, well, no value provided.

I think of my implementation as of flat Option. The benefit is that Some can be any value (including `null`) while there is no extra wrap object. I use a value that nobody can re-create.

You are also right about naming the None. I think it helps to understand why it is there.

And, as you show, potentially one could combine multiple named Options, with the benefit that the order of composition does not matter:

```

Option<"not-settled", Option<"empty", any>> === Option<"empty", Option<"not-settled", any>> === typeof NotSettled | typeof Empty | any

```

(with a small caveat that for type system `typeof NotSettled | typeof Empty | any` is the same as `any`).

I briefly looked into Ocaml docs, and when you use nullable, it's like the `Option.join` was called automatically. I want to prevent that.

--

--

Robin Pokorny
Robin Pokorny

Written by Robin Pokorny

Architecture & Tech Leadership — Speaks — Loves maths — Reads specs — Podcasts — Lives in Berlin — robinpokorny.com

No responses yet