Skip to content
Snippets Groups Projects
Commit ea9d6a67 authored by plw1g21's avatar plw1g21
Browse files

Changed how the hashmap is being implemented.

parent cdaeed64
No related branches found
No related tags found
No related merge requests found
import Data.HashTable.IO
import qualified Data.Map as Map
import Data.IORef
newMap :: IO (BasicHashTable String a)
newMap = new :: IO (BasicHashTable String a)
type MutableMap a = IORef (Map.Map String a)
newMap :: IO (MutableMap a)
newMap = newIORef Map.empty
insertMap :: BasicHashTable String a -> String -> a -> IO ()
insertMap = insert
insertMap :: MutableMap a -> String -> a -> IO ()
insertMap ref key value = modifyIORef' ref (Map.insert key value)
-- Look up a value in the hash map by key
lookupMap :: BasicHashTable String a -> String -> IO (Maybe a)
lookupMap = Data.HashTable.IO.lookup
lookupMap :: MutableMap a -> String -> IO (Maybe a)
lookupMap ref key = Map.lookup key <$> readIORef ref
......@@ -3,6 +3,7 @@ import Grammar
import System.Environment
import Control.Exception
import System.IO
import JHashtable
main :: IO ()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment