gcanti/fp-ts-local-storage

All local storage interactions are unsafe

samhh opened this issue · 2 comments

samhh commented

Per here, local storage can throw for many reasons, for example - something a project of mine has been bitten by before - the user having disabled it in their browser.

With this in mind, all of the APIs in this library are currently deceptively unsafe. Some options:

  1. Add documentation alluding to this unsafety
  2. Add new safe variants, and prefix the preexisting ones with unsafe
  3. Rewrite everything to be safe - presumably using E.tryCatch under the hood and asking for an error handler from the user - e.g. number -> IO<Option<string>> becomes (unknown -> E) -> number -> IO<Either<E, Option<string>>>

I think that a solution could be use IOEither and release a new major version of the library

Thanks @samhh

Add documentation alluding to this unsafety

This is a good first step.