From 6e7bfef2a8708e23837101c068e7d0dd656b04af Mon Sep 17 00:00:00 2001
From: Paul3103 <plw1g21@soton.ac.uk>
Date: Thu, 20 Apr 2023 12:04:28 +0100
Subject: [PATCH] Changed the name of the hashmap to a more appropriate name
 (HashTable->HashMap)

Currently I have only got the hashmap to accept string values, if I try
to store an int, then all hell breaks loose :(
---
 JHashMap.hs   | 33 +++++++++++++++++++++++++++++++++
 JHashtable.hs | 13 -------------
 Julio.hs      |  1 -
 3 files changed, 33 insertions(+), 14 deletions(-)
 create mode 100644 JHashMap.hs
 delete mode 100644 JHashtable.hs

diff --git a/JHashMap.hs b/JHashMap.hs
new file mode 100644
index 0000000..9ae75ab
--- /dev/null
+++ b/JHashMap.hs
@@ -0,0 +1,33 @@
+import qualified Data.Map as Map
+import Data.IORef
+
+main :: IO ()
+main = do
+  -- Create a new mutable map
+  julioHashMap <- newMap
+
+  -- insertMap will be called whenever an EqualsToken is located
+  insertMap julioHashMap "tile1" "valuesLoadedIn1"
+  insertMap julioHashMap "tile2" "42"
+
+
+  -- When a variable name is seen and not an equals, use "lookupMap"
+  val1 <- lookupMap julioHashMap "tile1"
+  val2 <- lookupMap julioHashMap "tile2"
+  val3 <- lookupMap julioHashMap "tile3" --No tile3 currently
+
+  -- Temporary just to check if working
+  putStrLn $ "tile1: " ++ show val1 
+  putStrLn $ "tile2: " ++ show val2 
+
+
+type MutableMap a = IORef (Map.Map String a)
+
+newMap :: IO (MutableMap a)
+newMap = newIORef Map.empty
+
+insertMap :: MutableMap a -> String -> a -> IO ()
+insertMap ref key value = modifyIORef' ref (Map.insert key value)
+
+lookupMap :: MutableMap a -> String -> IO (Maybe a)
+lookupMap ref key = Map.lookup key <$> readIORef ref
diff --git a/JHashtable.hs b/JHashtable.hs
deleted file mode 100644
index a97352e..0000000
--- a/JHashtable.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-import qualified Data.Map as Map
-import Data.IORef
-
-type MutableMap a = IORef (Map.Map String a)
-
-newMap :: IO (MutableMap a)
-newMap = newIORef Map.empty
-
-insertMap :: MutableMap a -> String -> a -> IO ()
-insertMap ref key value = modifyIORef' ref (Map.insert key value)
-
-lookupMap :: MutableMap a -> String -> IO (Maybe a)
-lookupMap ref key = Map.lookup key <$> readIORef ref
diff --git a/Julio.hs b/Julio.hs
index 821ff63..58b46a0 100644
--- a/Julio.hs
+++ b/Julio.hs
@@ -3,7 +3,6 @@ import Grammar
 import System.Environment
 import Control.Exception
 import System.IO
-import JHashtable
 
 
 main :: IO ()
-- 
GitLab