úÎ]îZ F      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEghcunstableAndy Gill <andygill@ku.edu>a real failure F | RewriteIdM exp -- ^ identity marker on a value a regular success F runs the  monad, returning a status. .How many transformations have been performed?  / lets you tunnel into the inner monad, because  is actually monad transformer.  . is our basic failure, with a String message.  ; catches failures, and tries a second monadic computation.  8 executes the first argument then the second, much like G, ] except that the second computation can see if the first computation was an identity or not. > Used to spot when a rewrite succeeded, but was the identity.  6 is used to mark a monadic rewrite as a non-identity, $ unless the congruence flag is set.  transparently, sets the congruence flag, such that if the 0 monadic action was identity preserving, then a   does ! not set the non-indentity flag. getDecsM reads the local environment mapDecsC changes the local environment, inside a local monadic invocation.  writeDecM/ writes a value to the writer monad inside the .    ghcunstableAndy Gill <andygill@ku.edu>6 is a translation or strategy that translates between exp1 and exp2!, with the posiblity of failure, & and remembers identity translations. H directly applies a  value to an argument. # is the standard way of building a -, where if the translation is successful it 9 is automatically marked as a non-identity translation. Note:  translate $ \ e -> return e is not3 an identity rewrite, but a succesful rewrite that ! returns its provided argument.  marks a  (or rewrite.) as transparent, that is the identity status ! of any internal applications of $ is preserved across the translate. Note: transparently $ translate $ \ e -> return e is an identity rewrite. ? executes the translation, returning either a failure message, 4 or a success and the new parts of the environment. ghcunstableAndy Gill <andygill@ku.edu>A  is a : that shares the same source and target type. Literally,  a # provides the details about how to re-write a specific type. - is our primitive way of building a Rewrite, \ where if the rewrite is successful it is automatically marked as a non-identity rewrite.  rewrite $ \ _ e -> return e is not an identity rewrite. ; executes the rewrite, returning either a failure message, 4 or a success and the new parts of the environment. ghcunstableAndy Gill <andygill@ku.edu>Failable structure. like a catch, N does the first translate , and if it fails, then does the second translate. like a ;] If the first translate succeeds, then do to the second translate after the first translate. failing translation. Xlook at the argument for the translation before choosing which translation to perform.  look at the dec* before choosing which translation to do. !add to the context dec,, which is propogated using a writer monad. " change the dec's for a scoped translation. ##6 promotes a function into an unfailable, non-identity . $$& always translates into an unfailable " that returns the first argument. %% composes a list of  into a single  which Is its result. &Aif the first rewrite is an identity, then do the second rewrite. 'if the first rewrite was not/ an identity, then also do the second rewrite. (catch a failing , making it into an identity. )Wif this is an identity rewrite, make it fail. To succeed, something must have changed. *Lrepeat a rewrite until it fails, then return the result before the failure. +Ylook at the argument to a rewrite, and choose to be either a failure of trivial success. ,identity rewrite. -failing rewrite. ./01234%Guarded translate or monadic action. J !"#$%&'()*+,-./01234 "!#$%&'()*+,-./01234 !"#$%&'()*+,-./0123455 captures how we walk over exp, using a specific m and dec. 66 applies 98 rewrites to all the interesting children of this node. 7allU applied a 9 Translation to a common, K9al result, to all the interesting children of this node. 88)s are things that syntax are built from. 99= is a sum of all the interesting sub-types, transitively, of exp.  We use  Generic e ~ e/ to signify that something is its own Generic. 1 Simple expression types might be their own sole 9, more complex examples " will have a new datatype for the 9*, which will also be an instance of class 8. :project projects into a 9#, to get the exp inside, or fails. ;; injects an exp into a 9. << converts a  over a 92 into a rewrite over a specific expression type. == converts a  taking a 94 into a translate over a specific expression type. >> promotes a  into a 9 ,; other types inside Generic cause failure.  try> can be used to convert a failure-by-default promotion into a 'id-by-default' promotion. ?? promotes a  into a 9 ,; other types inside Generic cause failure. @&apply a rewrite in a top down manner. A'apply a rewrite in a bottom up manner. BGapply a rewrite in a top down manner, prunning at successful rewrites. CXapply a rewrite twice, in a topdown and bottom up way, using one single tree traversal. D:a fixed point traveral, starting with the innermost term. E56789:;<=>?@ABCDE89:;567<>=?@ABCDE5676789:;9:;<=>?@ABCDEghcunstableAndy Gill <andygill@ku.edu>F  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEL       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJK LMNLOPQLORS kure-0.3.1Language.KURE.RewriteMonadLanguage.KURE.TranslateLanguage.KURE.RewriteLanguage.KURE.CombinatorsLanguage.KURE.Term Language.KURERewriteStatusMRewriteFailureMRewriteReturnMCount LoneTransformRewriteM runRewriteMtheCountliftQfailMcatchMchainMmarkMtransparentlyMreadEnvMmapEnvM writeEnvM Translateapply translate transparently runTranslateRewriterewrite runRewriteFailablefailure<+>->failTreaderTreadEnvT writeEnvTmapEnvTpureTconstTconcatT.+!->tryRchangedRrepeatRacceptRidRfailRtuple2RlistRmaybeRtuple2UlistUmaybeU?WalkerallRcrushUTermGenericselectinjectextractRextractUpromoteRpromoteUtopdownR bottomupRalltdRdownupR innermostRfoldUbaseGHC.Base>>= Data.Monoidmconcat countTransMonoid