-------------------------------------------------------------------------
--  
--     UseStore.hs
--  
--         Using the abstract data type Store of stores of integers.        
--                                  
--         (c) Addison-Wesley, 1996-2011.                   
--  
-------------------------------------------------------------------------


module UseStore where

import Store

-- Testing the exported definitions of the show and equality.                   

exam1 :: String
exam1 = Store -> String
forall a. Show a => a -> String
show Store
initial

exam2 :: Bool
exam2 = (Store
initial Store -> Store -> Bool
forall a. Eq a => a -> a -> Bool
== Store
initial) 

-- Can you check a Store against its representation? You need to uncomment
-- the definition before you use it.

-- checkAbs = (initial == Store [])

-- A complex store.

store3 :: Store
store3 = Store -> Var -> Integer -> Store
update (Store -> Var -> Integer -> Store
update (Store -> Var -> Integer -> Store
update Store
initial Var
'a' Integer
4) Var
'b' Integer
5) Var
'a' Integer
3

-- Show the store3.

exam3 :: String
exam3  = Store -> String
forall a. Show a => a -> String
show Store
store3 

-- Lookup 'a' in store3; can see that 'a' has the value 3 rather than 4.

exam4 :: Integer
exam4  = Store -> Var -> Integer
value Store
store3 Var
'a'