update :: Int -> GMState -> GMState
update n state 
    = putHeap heap' (putStack as state)
    where
    heap' = hUpdate (getHeap state) (as !! n) (NInd a)
    (a:as) = getStack state
update :: Int -> GMState -> GMState
update n state 
    = putHeap heap' (putStack as state)
    where
    heap' = hUpdate (getHeap state) (as !! n) (NInd a)
    (a:as) = getStack state
update n state 
    = putHeap heap' (putStack as state)
    where
    heap' = hUpdate (getHeap state) (as !! n) (NInd a)
    (a:as) = getStack state