This module defines a data type and various functions for interacting with the Storage interface of the Web Storage API. For example:

import Prelude
import Effect (Effect)
import Effect.Console (log, logShow)
import Web.HTML (window)
import Web.HTML.Window (localStorage)
import Web.Storage.Storage (clear, getItem, removeItem, setItem)

main :: Effect Unit
main = do
  w <- window
  s <- localStorage w
  setItem "this-is-my-key" "Here is my value." s
  v <- getItem "this-is-my-key" s
  logShow v

  removeItem "this-is-my-key" s
  v' <- getItem "this-is-my-key" s
  log "It is gone!"
  logShow v'

  clear s

#Storage Source

data Storage :: Type

#length Source

length :: Storage -> Effect Int

Returns the number of items in the storage.

#key Source

key :: Int -> Storage -> Effect (Maybe String)

Retrieves the key at the given index in the storage, if one exists.

#getItem Source

getItem :: String -> Storage -> Effect (Maybe String)

Retrieves the value stored at the given key, if one exists.

#setItem Source

setItem :: String -> String -> Storage -> Effect Unit

Given a key name and a value (in that order), adds that key to the storage or updates its value if it already exists.

#removeItem Source

removeItem :: String -> Storage -> Effect Unit

Removes the given key from the storage.

#clear Source

clear :: Storage -> Effect Unit

Clears all keys from the storage.