moduleLanguage.Syntactic.Sharing.StableNamewhereimportControl.Monad.IO.ClassimportData.IntMapasMapimportData.IORefimportSystem.Mem.StableNameimportUnsafe.CoerceimportLanguage.SyntacticimportLanguage.Syntactic.Sharing.Graph-- | 'StableName' of a @(c (Full a))@ with hidden result typedataStNamecwhereStName::StableName(c(Fulla))->StNamecinstanceEq(StNamec)whereStNamea==StNameb=a==unsafeCoerceb-- This is "probably" safe according to-- <http://www.haskell.org/pipermail/glasgow-haskell-users/2012-August/022758.html>-- TODO In future, use `eqStableName`. It should be in GHC 7.8.1.hash::StNamec->Inthash(StNamest)=hashStableNamest-- | A hash table from 'StName' to 'NodeId' (with 'hash' as the hashing-- function). I.e. it is assumed that the 'StName's at each entry all have the-- same hash, and that this number is equal to the entry's key.typeHistoryc=IntMap[(StNamec,NodeId)]-- | Lookup a name in the historylookHistory::Historyc->StNamec->MaybeNodeIdlookHistoryhistst=caseMap.lookup(hashst)histofNothing->NothingJustlist->Prelude.lookupstlist-- | Insert the name into the historyremember::StNamec->NodeId->Historyc->Historycrememberstnhist=insertWith(++)(hashst)[(st,n)]hist-- | Return a fresh identifier from the given supplyfresh::(Enuma,MonadIOm)=>IORefa->mafreshaRef=doa<-liftIO$readIORefaRefliftIO$writeIORefaRef(succa)returna