Y      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~  ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred *Apply a pure function to the result of an . ,Apply a pure function to the argument to an .  Apply an @ to the first element of a pair, discarding the second element.  Apply an @ to the second element of a pair, discarding the first element. A pure $ that swaps the elements of a pair. A pure  that duplicates its argument. Tag the result of an  with its argument. Tag the result of an  with its argument. !An arrow with a constant result. .Sequence (from left to right) a collection of s. Apply a collection of :s to the same input, combining their results in a monoid.     ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred  Similar to guard, but invokes  rather than mzero. As  $, but with a default error message. .if-then-else lifted over a monadic predicate. KIf the monadic predicate holds then perform the monadic action, else fail. KIf the monadic predicate holds then fail, else perform the monadic action.     ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred5 is the minimal structure that can be an instance of . ' The KURE user is free to either use  or provide their own monad.   is essentially the same as (  a), except that the ( method produces an error in the monad,  rather than invoking . W A major advantage of this is that monadic pattern match failures are caught safely. s with a catch for . * The following law is expected to hold:  fail msg `catchM` f == f msg %Catch a failing monadic computation. Eliminator for . Get the value from a 1, providing a function to handle the error case. 0A monadic catch that ignores the error message. OSelect the first monadic computation that succeeds, discarding any thereafter. NCatch a failing monadic computation, making it succeed with a constant value. <Catch a failing monadic computation, making it succeed with . NCatch a failing monadic computation, making it succeed with an error message. -Determine if a monadic computation succeeds.  Fail if the  succeeds; succeed with () if it fails. ;Modify the error message of a failing monadic computation. + Successful computations are unaffected. 8Set the error message of a failing monadic computation. + Successful computations are unaffected. DAdd a prefix to the error message of a failing monadic computation. + Successful computations are unaffected. MUse the given error message whenever a monadic pattern match failure occurs. ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred A !. that shares the same source and target type. !DAn abstract representation of a transformation from a value of type a in a context c to a monadic value of type m b.  The !/ type is the basis of the entire KURE library. "Apply a ! to a value and its context. # The primitive way of building a !. $ The primitive way of building a  . %Build a ! that doesn't depend on the context. &Build a ! that doesn't depend on the value. 'Build a constant ! from a monadic computation. Lifting through the E and a Reader transformer, where (c,a) is the read-only environment. The   induced by m., lifting through a Reader transformer, where c is the read-only environment. The   induced by m., lifting through a Reader transformer, where c is the read-only environment. The   induced by m., lifting through a Reader transformer, where c is the read-only environment. The   induced by m., lifting through a Reader transformer, where c is the read-only environment. The   induced by m., lifting through a Reader transformer, where c is the read-only environment. PLifting through a Reader transformer, where (c,a) is the read-only environment. PLifting through a Reader transformer, where (c,a) is the read-only environment. PLifting through a Reader transformer, where (c,a) is the read-only environment. PLifting through a Reader transformer, where (c,a) is the read-only environment. PLifting through a Reader transformer, where (c,a) is the read-only environment. PLifting through a Reader transformer, where (c,a) is the read-only environment.  !"#$%&' !"#$%&' !" "#$%&' !"#$%&'ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred($A class of injective functions from a to b, and their projections. * The following law is expected to hold:  project (inject a) == Just a +$Injects a value and lifts it into a . ,As -?, but takes a custom error message to use if projection fails. -%Projects a value and lifts it into a  MonadCatch#, with the possibility of failure. .Lifted ). /Lifted *, the ! fails if the projection fails. 0 Convert a ! over an injected value into a ! over a non-injected value. 1As 2>, but takes a custom error message to use if promotion fails. 2 Promote a ! over a value into a !" over an injection of that value, 9 (failing if that injected value cannot be projected). 3As 4?, but takes a custom error message to use if extraction fails. 4 Convert a   over an injected value into a  " over a projection of that value, 9 (failing if that injected value cannot be projected). 5As 6>, but takes a custom error message to use if promotion fails. 6 Promote a   into over a value into a  " over an injection of that value, 9 (failing if that injected value cannot be projected). .There is an identity injection for all types. ()*+,-./0123456()*+,-./0123456()*+-,./0214635()*+,-./0123456ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred7A 8. that shares the same source and target type. 8An undirected !. 9Extract the foreward ! from a 8. :Extract the backward ! from a 8. ; Construct a 8 from two opposite !s. <Try the 7* forewards, then backwards if that fails. ^ Useful when you know which rule you want to apply, but not which direction to apply it in. =3Invert the forewards and backwards directions of a 8. 789:;<=789:;<= 89:7;9:<=789:;<=ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred>The >" transformer, in combination with T and U,  causes a sequence of rewrites to only apply the first success, converting the remainder (and failures) to identity rewrites. ?The ?" transformer, in combination with R and S, ] causes a sequence of rewrites to succeed if at least one succeeds, converting failures to  identity rewrites. @ The identity  . AExtract the current context. B&Expose the current context and value. CMap a ! over a list. D An identity   with side-effects. ELook at the argument to the ! before choosing which ! to use. F Convert the monadic result of a !! into a result in another monad. GHPerform a collection of rewrites in sequence, requiring all to succeed. HEPerform two rewrites in sequence, succeeding if one or both succeed. IIPerform a collection of rewrites in sequence, succeeding if any succeed. As J&, but takes a custom failure message. JLook at the argument to an  =, and choose to be either the identity rewrite or a failure. KA generalisation of J where the predicate is a !. LCatch a failing Category, making it into an identity. M Makes an  5 fail if the result value equals the argument value. N Repeat a  < until it fails, then return the result before the failure. 3 Requires at least the first attempt to succeed. O Attempt each !I until one succeeds, then return that result and discard the rest of the !s. P1An identity translation that resembles a monadic join. Q>Fail if the Boolean is False, succeed if the Boolean is True. RWrap a   using the ? monad transformer. S Unwrap a   from the ? monad transformer. TWrap a   using the > monad transformer. U Unwrap a   from the > monad transformer. $>?@ABCDEFGHIJKLMNOPQRSTU>?@ABCDEFGHIJKLMNOPQRSTU@ABEFOCPQLGIHNJKMD?RS>TU!>?@ABCDEFGHIJKLMNOPQRSTU ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred( >?@ABCDEFGHIJKLMNOPQRSTUghcbeta"Neil Sculthorpe <neil@ittc.ku.edu>NoneVCtrace output of the value being rewritten; use for debugging only. VVVV ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred WA W. is a way to focus on a sub-structure of type b from a structure of type a. X Convert a W into a !N that produces a sub-structure (and its context) and an unfocussing function. Y The primitive way of building a W. [ If the unfocussing function is applied to the value focussed on then it should succeed, @ and produce the same value as the original argument (of type a). ZApply a   at a point specified by a W. [Apply a ! at a point specified by a W. \lCheck if the focusing succeeds, and additionally whether unfocussing from an unchanged value would succeed. ] The failing W. ^A W[ is deemed to have failed (and thus can be caught) if either it fails on the way down, or, { crucially, if it would fail on the way up for an unmodified value. However, actual failure on the way up is not caught 4 (as by then it is too late to use an alternative W)). This means that, in theory, a use of catch could cause a succeeding W application to fail.  But provided Y. is used correctly, this should never happen. _ Construct a W from a 8. ` Construct a W from two pure functions. aA W to the injection of a value. bA W to the projection of a value. WXYZ[\]^_`ab WXYZ[\]^_`ab WXYXZ[`]^\_ab WXYZ[\]^_`ab ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred?c>A path is a route to descend the tree from an arbitrary node. dContexts that are instances of d contain the current g. + Any user-defined combinators (typically i/ and congruence combinators) should update the g using f. e$Retrieve the current absolute path. f1Extend the current absolute path by one descent. gA path from the root. hhC captures the ability to walk over a tree containing nodes of type g,  using a specific context c. Minimal complete definition: i. %Default definitions are provided for l, m, j, k, and n, . but they may be overridden for efficiency. iApply a  < to all immediate children, succeeding if they all succeed. jApply a !< to all immediate children, succeeding if they all succeed. ! The results are combined in a . kApply a !8 to the first immediate child for which it can succeed. lApply a  6 to all immediate children, suceeding if any succeed. mApply a  8 to the first immediate child for which it can succeed. n Construct a W to the n-th child node. o2Count the number of children of the current node. pCDetermine if the current node has a child of the specified number. + Useful when defining custom versions of n. qApply a ! to a specified child. rApply a   to a specified child. s1Fold a tree in a top-down manner, using a single ! for each node. t2Fold a tree in a bottom-up manner, using a single ! for each node. uApply a !F to the first node for which it can succeed, in a top-down traversal. vApply a !G to the first node for which it can succeed, in a bottom-up traversal. wAttempt to apply a !- in a top-down manner, pruning at successes. x<An always successful top-down fold, replacing failures with . y=An always successful bottom-up fold, replacing failures with . z]An always successful traversal that collects the results of all successful applications of a ! in a list. {Like z), but does not traverse below successes. |Apply a  7 in a top-down manner, succeeding if they all succeed. }Apply a  8 in a bottom-up manner, succeeding if they all succeed. ~Apply a  J twice, in a top-down and bottom-up way, using one single tree traversal, # succeeding if they all succeed. Apply a  2 in a top-down manner, succeeding if any succeed. Apply a  3 in a bottom-up manner, succeeding if any succeed. Apply a  J twice, in a top-down and bottom-up way, using one single tree traversal,  succeeding if any succeed. Apply a  F to the first node for which it can succeed, in a top-down traversal. Apply a  G to the first node for which it can succeed, in a bottom-up traversal. Attempt to apply a  7 in a top-down manner, pruning at successful rewrites. :A fixed-point traveral, starting with the innermost term.  The (empty) g to the root. Lifted version of e.  Retrieve the c$ from the root to the current node. Lifted version of .  Find the c.s to every node that satisfies the predicate.  Find the cL to the first node that satisfies the predicate (in a pre-order traversal).  Find the cW to the first descendent node that satisfies the predicate (in a pre-order traversal).  Find the cNs to every node that satisfies the predicate, ignoring nodes below successes.  Find the c^ to the node that satisfies the predicate, failing if that does not uniquely identify a node. Build a c to the node that satisfies the predicate, failing if that does not uniquely identify a node (ignoring nodes below successes).  Construct a W by following a c.  Construct a W+ that points to the last node at which the c can be followed. !Repeat as many iterations of the c as possible. Build a W* from the root to a point specified by an g. Apply a   at a point specified by a c. Apply a ! at a point specified by a c. 'Check if it is possible to construct a W( along this path from the current node. Apply a  N to the largest node(s) that satisfy the predicate, requiring all to succeed. Apply a  O to the largest node(s) that satisfy the predicate, succeeding if any succeed. Apply a  b to the first node for which it can succeed among the largest node(s) that satisfy the predicate. Apply a !W to the largest node(s) that satisfy the predicate, combining the results in a monoid. Apply a !b to the first node for which it can succeed among the largest node(s) that satisfy the predicate. OTest if the type of the current node summand matches the type of the argument.  Note that the argument value? is never inspected, it is merely a proxy for a type argument. Wrap a ! using the  monad transformer.  Unwrap a ! from the  monad transformer. Wrap a ! using the  monad transformer.  Unwrap a ! from the  monad transformer. The simplest instance of d is g itself. gcdefghijklmnopqrstuvwxyz{|}~:cdefghijklmnopqrstuvwxyz{|}~:hijklmnrq|}~stuvwxyz{opgdefcXcdefghijklmnopqrstuvwxyz{|}~ ghcbeta"Neil Sculthorpe <neil@ittc.ku.edu> Safe-Inferred  !"#$%&'()*+,-./0123456>?@ABCDEFGHIJKLMNOPQRSTUcdefghijklmnopqrstuvwxyz{|}~  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc d e f g h i j k l m n o p q r s t u v w x y z { | } ~  .EKL d              t  kure-2.6.14Language.KURE.Combinators.ArrowLanguage.KURE.Combinators.MonadLanguage.KURE.MonadCatchLanguage.KURE.TranslateLanguage.KURE.InjectionLanguage.KURE.BiTranslate#Language.KURE.Combinators.TranslateLanguage.KURE.DebugLanguage.KURE.LensLanguage.KURE.WalkerLanguage.KURE.Combinators Language.KUREresultargumenttoFsttoSndswapfork forkFirst forkSecondconstant serialise paralleliseguardMsgguardMifMwhenMunlessMKureM MonadCatchcatchMrunKureM fromKureM<+catchesMtryMmtryMattemptMtestMnotM modFailMsg setFailMsg prefixFailMsgwithPatFailMsgRewrite Translateapply translaterewrite contextfreeT contextonlyTconstT InjectioninjectprojectinjectMprojectWithFailMsgMprojectMinjectTprojectTextractTpromoteWithFailMsgTpromoteTextractWithFailMsgRextractRpromoteWithFailMsgRpromoteR BiRewrite BiTranslate forewardT backwardT bidirectional whicheverRinvertOneRAnyRidRcontextTexposeTmapT sideEffectRreaderTresultTandR>+>orRacceptR accepterRtryRchangedRrepeatRcatchesTjoinTguardTwrapAnyR unwrapAnyRwrapOneR unwrapOneRdebugRLenslensTlensfocusRfocusT testLensTfailLcatchLbidirectionalLpureLinjectLprojectLPath PathContextabsPath@@ AbsolutePathWalkerallRallToneTanyRoneRchildL numChildrenT hasChildTchildTchildRfoldtdTfoldbuTonetdTonebuTprunetdTcrushtdTcrushbuTcollectT collectPruneTalltdRallbuRallduRanytdRanybuRanyduRonetdRonebuRprunetdR innermostR rootAbsPathabsPathTrootPath rootPathTpathsToT onePathToToneNonEmptyPathToT prunePathsToT uniquePathToTuniquePrunePathToTpathL exhaustPathL repeatPathLrootLpathRpathT testPathT allLargestR anyLargestR oneLargestR allLargestT oneLargestTsummandIsTypeTbase Control.ArrowArrowControl.CategoryCategoryGHC.Basefail Data.EitherEitherStringGHC.ErrerrorMonad Data.MonoidmemptySuccessFailure$fApplicativeKureM$fFunctorKureM$fMonadCatchKureM $fMonadKureM$fMonoidTranslate$fArrowApplyTranslateKleisli$fArrowPlusTranslate$fArrowZeroTranslate$fArrowTranslate$fCategoryTranslate$fMonadPlusTranslate$fMonadCatchTranslate$fMonadTranslate$fAlternativeTranslate$fApplicativeTranslate$fFunctorTranslate $fInjectionaaprojectWithFailMsgT$fInjectionaMaybe$fCategoryBiTranslateacceptWithFailMsgRPBoolcheckSuccessPBoolunAnyRunOneR$fMonadCatchOneR $fMonadOneR$fMonadCatchAnyR $fMonadAnyR$fCategoryLensMonoidwrapAllTAllT unwrapAllTwrapOneTOneT unwrapOneT$fPathContextAbsolutePathSetChildGetChildPIntP rmPathPrefix abs2pathTrequireUniquePathtryLpSndcheckSuccessPMaybeunAllTunOneT secondPInt unGetChild wrapGetChildunwrapGetChildgetChild unSetChild wrapSetChildunwrapSetChildsetChildchildL_default$fMonadCatchSetChild$fMonadSetChild$fMonadCatchGetChild$fMonadGetChild$fMonadCatchOneT $fMonadOneT$fMonadCatchAllT $fMonadAllT$fShowAbsolutePath