moduleDDC.Core.Simplifier.Base(-- * Simplifier SpecificationsSimplifier(..)-- * Transform Specifications,Transform(..),InlinerTemplates,NamedRewriteRules-- * Transform Results,TransformResult(..),TransformInfo(..),NoInformation,resultDone)whereimportDDC.Core.Simplifier.ResultimportDDC.Core.Transform.Rewrite.RuleimportDDC.Core.Transform.NamifyimportDDC.Core.ExpimportDDC.Type.EnvimportDDC.Base.PrettyimportqualifiedDDC.Core.Transform.SnipasSnipimportqualifiedDDC.Core.Transform.EtaasEtaimportqualifiedDDC.Core.Transform.BetaasBetaimportData.Monoid-- Simplifier ------------------------------------------------------------------- | Specification of how to simplify a core program.dataSimplifiersan-- | Apply a single transform.=Trans(Transformsan)-- | Apply two simplifiers in sequence.|Seq(Simplifiersan)(Simplifiersan)-- | Keep applying a transform until it reports that further-- applications won't be helpful, bailing out after a maximum number-- of applications.|FixInt(Simplifiersan)instanceMonoid(Simplifiersan)wheremempty=TransIdmappend=SeqinstancePretty(Simplifiersan)wherepprss=casessofSeqs1s2->pprs1<+>text";"<+>pprs2Fixis->text"fix"<+>inti<+>pprsTranst1->pprt1-- Transform -------------------------------------------------------------------- | Individual transforms to apply during simplification.dataTransformsan-- | The Identity transform returns the original program unharmed.=Id-- | Rewrite named binders to anonymous deBruijn binders.|Anonymize-- | Introduce let-bindings for nested applications.|SnipSnip.Config-- | Flatten nested let and case expressions.|Flatten-- | Perform beta reduction when the argument is not a redex.|BetaBeta.Config-- | Perform eta expansion and reduction.|EtaEta.Config-- | Remove unused, pure let bindings.|Prune-- | Float single-use bindings forward into their use sites.|Forward-- | Float casts outwards.|Bubble-- | Elaborate possible Const and Distinct witnesses that aren't-- otherwise in the program.|Elaborate-- | Inline definitions into their use sites.|Inline{-- | Get the unfolding for a named variable.transInlineDef::InlinerTemplatesan}-- | Apply general rule-based rewrites.|Rewrite{-- | List of rewrite rules along with their names.transRules::NamedRewriteRulesan}-- | Rewrite anonymous binders to fresh named binders.|Namify{-- | Create a namifier to make fresh type (level-1) -- names that don't conflict with any already in this-- environment.transMkNamifierT::Envn->Namifiersn-- | Create a namifier to make fresh value or witness (level-0) -- names that don't conflict with any already in this-- environment.,transMkNamifierX::Envn->Namifiersn}-- | Function to get the inliner template (unfolding) for the given name.typeInlinerTemplatesan=(n->Maybe(Expan))-- | Rewrite rules along with their names.typeNamedRewriteRulesan=[(String,RewriteRulean)]instancePretty(Transformsan)wherepprss=casessofId->text"Id"Anonymize->text"Anonymize"Snip{}->text"Snip"Flatten->text"Flatten"Beta{}->text"Beta"Eta{}->text"Eta"Prune->text"Prune"Forward->text"Forward"Bubble->text"Bubble"Inline{}->text"Inline"Namify{}->text"Namify"Rewrite{}->text"Rewrite"Elaborate->text"Elaborate"