X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FbasicTypes%2FUniqSupply.lhs;h=493bfbe6dba572509c119692d2c51782f114b1a6;hp=cb1a1fc69f11effb153baa990843575507a99a69;hb=edc0bafd3fcd01b85a2e8894e5dfe149eb0e0857;hpb=893a3c0ad6c39caf71ac28af900733513e1f153e diff --git a/compiler/basicTypes/UniqSupply.lhs b/compiler/basicTypes/UniqSupply.lhs index cb1a1fc..493bfbe 100644 --- a/compiler/basicTypes/UniqSupply.lhs +++ b/compiler/basicTypes/UniqSupply.lhs @@ -8,15 +8,16 @@ module UniqSupply ( -- * Main data type UniqSupply, -- Abstractly - -- ** Operations on supplies + -- ** Operations on supplies uniqFromSupply, uniqsFromSupply, -- basic ops - + takeUniqFromSupply, + mkSplitUniqSupply, splitUniqSupply, listSplitUniqSupply, -- * Unique supply monad and its abstraction UniqSM, MonadUnique(..), - + -- ** Operations on the monad initUs, initUs_, lazyThenUs, lazyMapUs, @@ -30,8 +31,7 @@ import FastTypes import MonadUtils import Control.Monad -import Control.Monad.Fix -import GHC.IOBase (unsafeDupableInterleaveIO) +import GHC.IO (unsafeDupableInterleaveIO) \end{code} @@ -67,6 +67,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} @@ -95,6 +97,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} %************************************************************************