Package

purescript-purversion

Repository
Quelklef/purversion
License
MIT
Uploaded by
Quelklef
Published on
2021-02-16T08:04:20Z

Richly-typed and versioned localStorage keys for Purescript

Super Simple API

  1. Register your localStorage key

    pv <- Purversion.make
          { key: "a-localstorage-key"  -- key name
          , encode: intToString        -- data encoding. we're storing integers
          , decode: stringToInt
          , migrations: [Identity]     -- data migrations, if applicable
          }

    Note that the monad is just Effect, nothing special.

  2. Save and load values

    -- Put a value into the key
    Purversion.save pv 100
    
    -- Get a value out of the key
    value <- Purversion.load pv
    log $ show value  -- 100
  3. No step 3. That's it!

Documentation

Enjoy!