úÎN¹KW8      !"#$%&'()*+,-./01234567ghcunstableAndy Gill <andygill@ku.edu>a real failure F | RewriteIdM exp -- ^ identity marker on a value a regular success 89:;< runs the  monad, returning a status. / 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 =, ] 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.  , sets the congruence flag, such that if the 0 monadic action was identity preserving, then a   does ! not set the non-indentity flag.   reads the local environment mapDecsC changes the local environment, inside a local monadic invocation.    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. > 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. ? 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.  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 ?s 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. '%Guarded translate or monadic action. @ !"#$%&' !"#$%&' !"#$%&'(( captures how we walk over exp, using a specific m and dec. )) applies ,8 rewrites to all the interesting children of this node. *allU applied a , Translation to a common, A9al result, to all the interesting children of this node. ++)s are things that syntax are built from. ,,= 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 ,, more complex examples " will have a new datatype for the ,*, which will also be an instance of class +. -project projects into a ,& exp, to get the exp inside, or fail.  TODO: rename as select .. injects an exp into a , exp. /extract converts a  over a ,2 into a rewrite over a specific expression type. 0promote promotes a  into a , ,; other types inside Generic cause failure.  try> can be used to convert a failure-by-default promotion into a 'id-by-default' promotion. 1accept 234567()*+,-./01234567+,-.()*/01234567()*)*+,-.,-./01234567ghcunstableAndy Gill <andygill@ku.edu>8  !"#$%&'()*+,-./01234567B      !"#$%&'()*+,-./0123456789:;<=>?@AB CDECFGHCFIJ kure-0.2.2Language.KURE.RewriteMonadLanguage.KURE.TranslateLanguage.KURE.RewriteLanguage.KURE.CombinatorsLanguage.KURE.Term Language.KURERewriteStatusMRewriteFailureMRewriteReturnMRewriteM runRewriteMliftQfailMcatchMchainMmarkM transparentlygetDecsMmapDecsM Translateapply translate runTranslateRewriterewrite runRewriteFailablefailure<+>->failTreaderTgetDecsTmapDecsTpureTconstTconcatT.+!->tryRchangedRrepeatRacceptRidRfailR?WalkerallRcrushUTermGenericselectinjectextractRpromoteRextractUtopdownR bottomupRalltdRdownupR innermostRfoldUIdStatusNotIdIsIdEmptyIdbaseGHC.Base>>= Data.MonoidmconcatwasIdMonoid