úÎ(v%ä     portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferedsubstitute p a w replaces the free variable a with p in w ZIf a term has no free variables, you can freely change the type of free variables it uses portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Infered,This may or may not be a monad transformer, If it is, then you can use m >>>= f = m >>= lift . f CThis is useful for types like expression lists, case alternatives, I schemas, etc. that may not be expressions in their own right, but often  contain one. portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Infered !" !"portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Infered  Scope b f a is a an f$ expression with bound variables in b, and free variables in a KThis stores bound variables as their generalized de Bruijn representation,  in that the succ'As for variable ids are allowed to occur anywhere within the tree  permitting O(1)5 weakening and allowing more sharing opportunities. + Here the deBruijn 0 is represented by the  constructor of  , while the  de Bruijn #9 (which may be applied to an entire tree!) is handled by . 6NB: equality and comparison quotient out the distinct  placements allowed by l the choice of a generalized de Bruijn representation and return the same result as a traditional de Bruijn  representation would. SCapture some free variables in an expression to yield a Scope with bound variables  Abstract over a single variable 1Enter a scope, instantiating all bound variables 8Enter a scope with one bound variable, instantiating it  fromScope5 quotients out the possible placements of F in Scope I distributing them all to the leaves. This yields a traditional deBruijn & indexing scheme for bound variables.   fromScope . toScope = id - fromScope . toScope . fromScope = fromScope (toScope . fromScope) is idempotent APerform substitution on both bound and free variables in a scope $SThe monad permits substitution on free variables, while preserving bound variables %toList< is provides a list (with duplicates) of the free variables  &'()*+,-./$0%1    &'()*+,-./$0%1portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Infered 2      !"#$%&'()*+,-./012345678 bound-0.1.1 Bound.Term Bound.Class Bound.Var Bound.ScopeBound substituteclosedisClosed>>>==<<<VarFBScopeunscopeabstract abstract1 instantiate instantiate1 fromScopetoScopesplat $fRead1Var $fShow1Var $fOrd1Var$fEq1Var $fRead2Var $fShow2Var $fOrd2Var$fEq2Var$fBitraversableVar$fBifoldableVar$fBifunctorVar $fMonadVar$fApplicativeVar$fTraversableVar $fFoldableVar $fFunctorVarbaseGHC.Enumsucc $fMonadScope$fFoldableScope $fBoundScope $fRead1Scope $fReadScope $fShow1Scope $fShowScope $fOrd1Scope $fOrdScope $fEq1Scope $fEqScope$fMonadTransScope$fTraversableScope$fFunctorScope