moduleDDC.Type.Transform.AnonymizeT(anonymizeT,AnonymizeT(..),pushAnonymizeBindT)whereimportDDC.Type.ExpimportDDC.Type.CompoundsimportData.ListimportqualifiedDDC.Type.SumasT-- | Rewrite all binders in a thing to be of anonymous form.anonymizeT::(Ordn,AnonymizeTc)=>cn->cnanonymizeTxx=anonymizeWithT[]xx-------------------------------------------------------------------------------classAnonymizeT(c::*->*)where-- | Rewrite all binders in a thing to be of anonymous form.-- -- The stack contains existing anonymous binders that we have entered into,-- and named binders that we have rewritten. All bound occurrences of variables-- will be replaced by references into this stack.anonymizeWithT::foralln.Ordn=>[Bindn]->cn->cninstanceAnonymizeTTypewhereanonymizeWithTkstacktt=casettofTVaru->TVar$anonymizeWithTkstackuTCon{}->ttTForallbt->let(kstack',b')=pushAnonymizeBindTkstackbinTForallb'(anonymizeWithTkstack't)TAppt1t2->TApp(anonymizeWithTkstackt1)(anonymizeWithTkstackt2)TSumss->TSum(anonymizeWithTkstackss)instanceAnonymizeTTypeSumwhereanonymizeWithTkstackss=T.fromList(anonymizeWithTkstack$T.kindOfSumss)$map(anonymizeWithTkstack)$T.toListssinstanceAnonymizeTBoundwhereanonymizeWithTkstackbb=casebbofUName_|Justix<-findIndex(boundMatchesBindbb)kstack->UIxix_->bb-- Push ------------------------------------------------------------------------ | Push a binding occurrence of a level-1 variable on the stack, -- returning the anonyized binding occurrence and the new stack.pushAnonymizeBindT::Ordn=>[Bindn]-- ^ Stack for Spec binders (level-1)->Bindn->([Bindn],Bindn)pushAnonymizeBindTkstackb=lett'=typeOfBindbkstack'=b:kstackin(kstack',BAnont')