re: The Maybe data type in JavaScript VIEW POST

re: Also, no, nothing is not the concept of undefined. You might expect output as an undefined and do a check on it, but things change and later you ...
  1. Yes, I will have to add checks. But I have to add checks for this too, the instance of Nothing will have to be returned too for all the empty array, string cases. I get this is more easier to read and understand. But I could as simply check with isUndefined. And if I'm going to wrap every result in an Nothing/Just I could maintain consistency with returning undefined too.
  2. That doesn't happen automatically, have to validate the input. If there's validation logic already, then undefined can be a safe choice too as long my own code knows to expect it.

I'm not against the idea, I just think this is maybe better as a Type in Typescript then a class. No need to complicate which can be just:
Maybe = T | undefined

Or maybe I haven't understood this completely, will have a look at some more articles.

Yeah I don't think I'm able to explain the idea to you well enough; I hope you find the right resources online! Just to set the right context; no; you will not have to add any checks if you're using ADTs and mapping over them. The reason to use them is to remove all these unnecessary checks.

code of conduct - report abuse