-- | Inlining definitions into their use sites.moduleDDC.Core.Transform.Inline(inline,InlineSpec(..),lookupTemplateFromModules)whereimportDDC.Core.ExpimportDDC.Core.ModuleimportDDC.Core.Transform.Inline.TemplatesimportqualifiedData.SetasSetimportData.Set(Set)classInline(c::*->*->*)whereinline::Ordn=>(n->Maybe(Expan))-- ^ Get the template for a named variable.->Setn-- ^ Don't inline definitions for these names.->can->caninstanceInlineModulewhereinlinegetinsidemm=mm{moduleBody=inlinegetinside(moduleBodymm)}instanceInlineExpwhereinlinegetinsidexx=letdownx=inlinegetinsidexincasexxofXVar_(UNamen)-- Don't inline a recursive definition into itself.|Set.memberninside->xx-- If there is a template for this variable then inline it, -- but remember that we're now inside the body so we don't inline-- recursive functions forever.|Justxx'<-getn->let!inside'=Set.insertninsideininlinegetinside'xx'XVar{}->xxXCon{}->xxXLAMabx->XLAMab(downx)XLamabx->XLamab(downx)XAppax1x2->XAppa(downx1)(downx2)XLetaltsx2->XLeta(downlts)(downx2)XCaseaxalts->XCasea(downx)(mapdownalts)XCastacx->XCastac(downx)XType{}->xxXWitness{}->xxinstanceInlineLetswhereinlinegetinsidelts=letenterbx=casebofBNamen_->inlineget(Set.insertninside)x_->inlinegetinsidexincaseltsofLLetbx->LLetb(enterbx)LRecbxs->LRec[(b,enterbx)|(b,x)<-bxs]LLetRegions{}->ltsLWithRegion{}->ltsinstanceInlineAltwhereinlinegetinsidealt=casealtofAAltpx->AAltp(inlinegetinsidex)