@@ -15,15 +15,15 @@ import Control.Monad.Eff (Eff)
1515import Control.Monad.Eff.Unsafe (unsafePerformEff)
1616import Control.Monad.Eff.Ref (REF, Ref, newRef, writeRef, modifyRef')
1717
18−import Data.Map as M
18+import Data.Function.Uncurried as Fn
1919import Data.Maybe (Maybe(..))
20−import Data.Vault.Internal (Unique, newUnique)
20+import Data.Vault.Internal as V
2121
2222-- | A persistent store for values of arbitrary types.
23−newtype Vault = Vault (M.Map Unique Item)
23+newtype Vault = Vault (V.UniqueMap Item)
2424
2525-- | Key for an item in vault
26−data Key a = Key Unique (Item' a)
26+data Key a = Key V.Unique (Item' a)
2727
2828type Item = Eff (ref :: REF) Unit
2929
@@ -31,33 +31,33 @@ type Item' a = Ref (Maybe a)
3131
3232-- | The empty vault
3333empty :: Vault
34−empty = Vault M.empty
34+empty = Vault V.empty
3535
3636-- | Create a new key for use with a vault.
3737newKey :: forall eff a. Eff (ref :: REF | eff) (Key a)
3838newKey = do
39− k <- newUnique
39+ k <- V.newUnique
4040 ref <- newRef Nothing
4141 pure $ Key k ref
4242
4343-- | Insert a value for a given key. Overwrites any previous value.
4444insert :: forall a. Key a -> a -> Vault -> Vault
45−insert (Key k ref) a (Vault m) = Vault (M.insert k (writeRef ref (Just a)) m)
45+insert (Key k ref) a (Vault m) = Vault (Fn.runFn3 V.insert k (writeRef ref (Just a)) m)
4646
4747-- | Delete a key from the vault.
4848delete :: forall a. Key a -> Vault -> Vault
49−delete (Key k _) (Vault m) = Vault (M.delete k m)
49+delete (Key k _) (Vault m) = Vault (Fn.runFn2 V.delete k m)
5050
5151-- | Lookup the value of a key in the vault.
5252lookup :: forall a. Key a -> Vault -> Maybe a
53−lookup (Key k ref) (Vault m) = case M.lookup k m of
53+lookup (Key k ref) (Vault m) = case Fn.runFn4 V.lookup Nothing Just k m of
5454 Nothing -> Nothing
5555 Just act -> unsafePerformEff do
5656 _ <- act
5757 modifyRef' ref rollItem
5858
5959union :: Vault -> Vault -> Vault
60−union (Vault m) (Vault n) = Vault (M.union m n)
60+union (Vault m) (Vault n) = Vault (Fn.runFn2 V.union m n)
6161
6262rollItem :: forall a. Maybe a -> { state :: Maybe a, value :: Maybe a }
6363rollItem a = { state: Nothing, value: a }