r/purescript • • Mar 14 '16

Announcing purescript-localstorage - alpha testers appreciated :-)

https://pursuit.purescript.org/packages/purescript-localstorage/0.1.2

Typesafe local storage, with a minimum amount of boilerplate.

I just finished it, it compiles and the basic example in test/Main.purs works, otherwise it is completely untested.

Enjoy! (Bug reports welcome!)

10 Upvotes

7 comments sorted by

View all comments

Show parent comment

1

u/tuxkimo Mar 25 '16

You got this right. You can use the Raw interface if you like, but I don't really get why anyone would want this.

The type safe interface basically only requires you to list the keys you are going to use. (Ok currently additional smart constructors are needed) Which is really very little work (this was actually a very important design criteria) and saves you from misspelling keys or using the wrong key!

Also, because the keys encode the type you are going to retrieve, you will never need any type annotations. If keys were plain strings and you would retrieve a value, let's say from the repl, a type annotation would be necessary. - So especially if you just want to try it out an explicit key type makes sense.

Ok, having said that: I am not opposed to including an additional interface where keys are strings, and values are encoded/decoded for you. If people want/need that, I am happy to accept my first pull request :-)