Define takeUniqFromSupply
[ghc-hetmet.git] / compiler / basicTypes / UniqSupply.lhs
index 43ccbe3..a4c16fd 100644 (file)
@@ -10,6 +10,7 @@ module UniqSupply (
 
         -- ** Operations on supplies
         uniqFromSupply, uniqsFromSupply, -- basic ops
+        takeUniqFromSupply,
 
         mkSplitUniqSupply,
         splitUniqSupply, listSplitUniqSupply,
@@ -70,6 +71,8 @@ uniqFromSupply  :: UniqSupply -> Unique
 -- ^ Obtain the 'Unique' from this particular 'UniqSupply'
 uniqsFromSupply :: UniqSupply -> [Unique] -- Infinite
 -- ^ Obtain an infinite list of 'Unique' that can be generated by constant splitting of the supply
+takeUniqFromSupply :: UniqSupply -> (Unique, UniqSupply)
+-- ^ Obtain the 'Unique' from this particular 'UniqSupply', and a new supply
 \end{code}
 
 \begin{code}
@@ -98,6 +101,7 @@ listSplitUniqSupply  (MkSplitUniqSupply _ s1 s2) = s1 : listSplitUniqSupply s2
 \begin{code}
 uniqFromSupply  (MkSplitUniqSupply n _ _)  = mkUniqueGrimily (iBox n)
 uniqsFromSupply (MkSplitUniqSupply n _ s2) = mkUniqueGrimily (iBox n) : uniqsFromSupply s2
+takeUniqFromSupply (MkSplitUniqSupply n s1 _) = (mkUniqueGrimily (iBox n), s1)
 \end{code}
 
 %************************************************************************