+%************************************************************************
+%* *
+\subsection{Binary}
+%* *
+%************************************************************************
+
+\begin{code}
+instance Binary Name where
+ put_ bh name = do
+ case getUserData bh of {
+ UserData { ud_symtab_map = symtab_map_ref,
+ ud_symtab_next = symtab_next } -> do
+ symtab_map <- readIORef symtab_map_ref
+ case lookupUFM symtab_map name of
+ Just (off,_) -> put_ bh off
+ Nothing -> do
+ off <- readFastMutInt symtab_next
+ writeFastMutInt symtab_next (off+1)
+ writeIORef symtab_map_ref
+ $! addToUFM symtab_map name (off,name)
+ put_ bh off
+ }
+
+ get bh = do
+ i <- get bh
+ return $! (ud_symtab (getUserData bh) ! i)
+\end{code}