dhruvrajvanshi / ts-failable

Type safe error handling library for Typescript
MIT License
90 stars 2 forks source link

Generalizing the framework #3

Open yang opened 3 years ago

yang commented 3 years ago

Thanks for the wonderful library!

Would you consider generalizing this beyond error-handling and and threading any monadic context?

I had written something similar for Optional types. Such that you can do (using your syntax):

const key = run(user.username);
const value = run(map.get(key));
// etc.

I thought at least Optional made sense for your library since it already includes related work (deprecated by existential chaining).

dhruvrajvanshi commented 3 years ago

Not sure if it is possible to generalize this to all monads in a type-safe way because that would require higher kinded types, which typescript doesn't have. Keeping this open but I highly doubt if this is possible.