v      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                  ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 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 [ \ ] ^ _ ` 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 { | } ~                                                                             Safe-Inferred  NoneNone  None3The PN is the name as it occurs to the parser, and " corresponds with the GHC.RdrName  type PN = GHC.RdrName .HsName is a name as it is found in the source , This seems to be quite a close correlation BThe PNT is the unique name, after GHC renaming. It corresponds to D GHC.Name data PNT = PNT GHC.Name deriving (Data,Typeable) -- Note: # GHC.Name has SrcLoc in it already      NoneShow a GHC API structure None$2Match a SrcSpan, using a ForestLine as the marker (The length of the  span may have  changed due to  updated tokens. ,9An entry in the data structure for a particular srcspan. -"The gap between this span end and  the start of the next in the  fringe of the tree. .The tokens for the SrcSpan if  subtree is empty />Identifies the tree carrying the main tokens, not any work in  progress or deleted ones  !"#$%&'()*+,-./ !"#$%&'()*+,-./,.-&'()*+%$"# !/  !"#$%&'()*+,.-/None1?Provide some temporary storage while the refactoring is taking  place 5:Result of parsing a Haskell source file. It is simply the $ TypeCheckedModule produced by GHC. 6*State for refactoring a single file. Holds/hides the token 9 stream, which gets updated transparently at key points. 8Session level settings 9@Current Unique creator value, incremented every time it is used :)Flags for controlling generic traversals ;Temporary storage of values  while refactoring takes place <$The current module being refactored ?,Current traversal has already made a change C-Original Token stream for the current module DJToken stream for the current module, maybe modified, in SrcSpan tree form E,current module has updated the token stream NThe sandbox directory. W9Initialise the GHC session, when starting a refactoring. ) This should never be called directly. 10123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY*0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY*5QTSRHIJKLMNOP6789:;<@ABCDEFG=>?14320XYUVW0143256789:;<=>?@ABCDEFGHIJKLMNOPQTSRUVWXYNone[3Look up a subterm by means of a maybe-typed filter \2Apply a monadic transformation at least somewhere ]FApply a monadic transformation at least somewhere, in bottom up order ^ Monadic variation on everywhere _Monadic variation on everywhere' `Bottom-up transformation a%Top-down version of everywhereStaged KChecks whether the current item is undesirable for analysis in the current  AST Stage. #Staged variation of SYB.everything E The stage must be provided to avoid trying to modify elements which 5 may not be present at all stages of AST processing.  Note: Top-down order c Staged variation of SYB.listify E The stage must be provided to avoid trying to modify elements which 5 may not be present at all stages of AST processing. d0Full type-unifying traversal in top-down order. e<Top-down type-unifying traversal that is cut of below nodes ) where the argument strategy succeeds. g>Top-down type-preserving traversal that performs its argument  strategy at most once. h?Bottom-up type-preserving traversal that performs its argument  strategy at most once. mAApply a generic transformation everywhere in a bottom-up manner. n=Open a zipper to the point where the Geneneric query passes. E returns the original zipper if the query does not pass (check this) o;Apply a generic monadic transformation once at the topmost D leftmost successful location, avoiding holes in the GHC structures p5Transform a zipper opened with a given generic query q@Monadic transform of a zipper opened with a given generic query s'Climb the tree until a predicate holds tBUp the zipper until a predicate holds, and then return the zipper  hole u;Open a zipper to the point where the Generic query passes, @ returning the zipper and a value from the specific part of the C GenericQ that matched. This allows the components of the query to K return a specific transformation routine, to apply to the returned zipper v;Open a zipper to the point where the Generic query passes, E and apply the transformation returned from the specific part of the  GenericQ that matched. Z[\]^_`abcdefghijklmnopqrstuvZ[\]^_`abcdefghijklmnopqrstuvZ[\]^_`acbdefghijklmnopquvrstZ[\]^_`abcdefghijklmnopqrstuvNone!$Returns True if the token ends with '\n'  ++AZ++: is this meaningful? &Returns True if the token starts with `\n`.  ++AZ++: is this meaningful? 0get the last non-space token in a token stream. )Remove the extra preceding empty lines. (Remove the following extra empty lines. =Convert a string into a set of Haskell tokens, following the E given position, with each line indented by a given column offset if  required  TODO: replace 'colOffset withFirstLineIndent' with a Maybe Int ++AZ++ >Convert a string into a set of Haskell tokens. It has default I position and offset, since it will be stitched into place in TokenUtils QGiven a token stream covering multi-lines, calculate the length of the last line ? AZ: should be the last token start col, plus length of token. <get a token stream specified by the start and end position. CReplace a single token in the token stream by a new token, without  adjusting the layout. C Note1: does not re-align, else other later replacements may fail. E Note2: must keep original end col, to know what the inter-token gap  was when re-aligning ETransfer the location information from the first param to the second *Get the start of the line before the pos, @Delete a sequence of tokens specified by the start position and E end position from the token stream, then adjust the remaining token  stream to preserve layout @Adjust the layout to compensate the change in the token stream. =remove at most n white space tokens from the beginning of ts @get all the source locations (use locations) in an AST phrase t 4 according the the occurrence order of identifiers. 8Get all the source locations in a given syntax fragment CExtend the given position backwards to the front of the file while  the supplied condition holds @Extend the given position forwards to the end of the file while  the supplied condition holds  Get the start&5end location of syntax phrase t, then extend the end  location to cover the comment/&white spaces or new line which starts & in the same line as the end location : TODO: deprecate this in favour of startEndLocIncComments ?Split the token stream into three parts: the tokens before the B startPos, the tokens between startPos and endPos, and the tokens  after endPos. F Note: The startPos and endPos refer to the startPos of a token only. @ So a single token will have the same startPos and endPos  NO^^^^ BGet around lack of instance Eq when simply testing for empty list  Get the start&3end location of t in the token stream, then extend A the start and end location to cover the preceding and following  comments. KSplit a set of comment tokens into the ones that belong with the startLine ( and those that belong with the endLine 3Get the first SrcSpan found, in top down traversal ?Get the indent of the line before, taking into account in-line  'where', 'let', 'in' and 'do' tokens >sort out line numbering so that they are always monotonically  increasing. @Adjust token stream to cater for changes in token length due to  token renaming /Compose a new token using the given arguments. :Add a constant line and column offset to a span of tokens AUsed as a marker in the filename part of the SrcSpan on modified = tokens, to trigger re-alignment when retrieving the tokens. >Mark a token so that it can be use to trigger layout checking # later when the toks are retrieved &Does a token have the file mark in it Zwxyz{|}~Uwxyz{|}~Uxyz{w|}~Zwxyz{|}~ None>CHow new SrcSpans should be inserted in the Token tree, relative to  the prior span Line and Col offset for $ start, num lines to add at the end 0 relative to the indent level of the prior line Line and Col offset for $ start, num lines to add at the end 0 relative to the indent level of the prior span Line offset and  absolute Col. Mainly  for forcing start at  left margin, number  of lines to add at  the end Start at the specified  line and col  Only a single space between the ' end of the prior span and the new one ;Keep track of when tokens are reversed, to avoid confusion .Extract an encoded ForestLine from a GHC line Gets the version numbers Gets the AST tree numbers !Gets the SpanLengthChanged flags 5Checks if the version is non-zero in either position 0Checks if the version is zero in both positions "Checks if the version is non-zero &Checks if the AST version is non-zero Checks if the version is zero  Puts a TreeId into a forestSpan Strip out the version markers Strip out the version markers @Assuming most recent operation has stashed the old tokens, sync . the given AST to the most recent stash entry >Get the (possible cached) tokens for a given source span, and  cache their being fetched. C NOTE: The SrcSpan may be one introduced by HaRe, rather than GHC. C TODO: consider returning an Either. Although in reality the error  should never happen !Get the tokens preceding a given SrcSpan =Replace a single token in a token tree, without changing the  structure of the tree D NOTE: the GHC.SrcSpan may have been used to select the appropriate B forest in the first place, and is required to select the correct I span in the tree, due to the ForestLine annotations that may be present BReplace the tokens for a given SrcSpan with new ones. The SrcSpan < will be inserted into the tree if it is not already there. A If the SrcSpan changes size, replace the SrcSpan with a new one 1 (marked), and return it, as well as the old one : TODO: What about trailing comments? Preserve or replace? ERetrieve a path to the tree containing a ForestSpan from the forest, % inserting it if not already present AInsert a ForestSpan into the forest, if it is not there already. A Assumes the forest was populated with the tokens containing the  ForestSpan already DTrue if the start of the second param lies in the span of the first ATrue if the start of the second param lies before the first, and  ends after or on the second BTrue if the end of the second param lies in the span of the first CSplit a given tree into a possibly empty part that lies before the B srcspan, the part that is wholly included in the srcspan and the ) part the lies outside of it at the end. 5Removes a ForestSpan and its tokens from the forest. BFor a span about to be deleted, calculate the gap between the end E of the span being deleted and the start of the next one, at a token  level. =Retrieve all the tokens at the leaves of the tree, in order. 4 Marked tokens are re-aligned, and gaps are closed. @Retrieve all the tokens at the leaves of the tree, in order. No D adjustments are made to address gaps or re-alignment of the tokens Merge adjacent Deleted entries =Process the leaf nodes of a tree to remove all deleted spans =Process the leaf nodes of a tree to remove all deleted spans CStarting from a point in the zipper, retrieve all tokens backwards ) until the line changes for a non-comment/non-empty token or  beginning of file. @Some tokens are marked if they belong to identifiers which have C been renamed. When the renaming takes place, no layout adjustment E is done. This function adjusts the spacing for the rest of the line B to match as far as possible the original spacing, except for the  name change. CAdd a new SrcSpan and Tokens after a given one in the token stream B and forest. This will be given a unique SrcSpan in return, which ' specifically indexes into the forest.  CAdd new tokens after the given SrcSpan, constructing a new SrcSpan  in the process  CAdd new tokens belonging to an AST fragment after a given SrcSpan, 8 and re-sync the AST fragment to match the new location BExtract the start and end position of a span, without any leading  or trailing comments @Convert a simple (start,end) position to a SrcSpan belonging to  the file in the tree @Convert a simple (start,end) position to a SrcSpan belonging to  the file in the given token 7Insert a new node after the designated one in the tree 2Open a zipper so that its focus is the given node - NOTE: the node must already be in the tree @Does the first span contain the second? Takes cognisance of the & various flags a ForestSpan can have. > NOTE: This function relies on the Eq instance for ForestLine =Open a zipper so that its focus has the given SrcSpan in its D subtree, or the location where the SrcSpan should go, if it is not  in the tree ASplit a forest of trees into a (begin,middle,end) according to a H ForestSpan, such that no tokens are included in begin or end belonging F to the ForestSpan, and all of middle has some part of the ForestSpan OUtility function to either return True or throw an error to report the problem KCheck the invariant for the token cache. Returns list of any errors found.  Invariants: O 1. For each tree, either the rootLabel has a SrcSpan only, or the subForest /= []. [ 2a. The trees making up the subForest of a given node fully include the parent SrcSpan. D i.e. the leaves contain all the tokens for a given SrcSpan. ) 2b. The subForest is in SrcSpan order W 3. A given SrcSpan can only appear (or be included) in a single tree of the forest. X 4. The parent link for all sub-trees does exist, and actually points to the parent. 0 5. There are no nullSpan entries in the tree O NOTE: the tokens may extend before or after the SrcSpan, due to comments only I NOTE2: this will have to be revisited when edits to the tokens are made )Get the start and end position of a Tree 1 treeStartEnd :: Tree Entry -> (SimpPos,SimpPos) N treeStartEnd (Node (Entry sspan _) _) = (getGhcLoc sspan,getGhcLocEnd sspan) ,Get the start and end position of a SrcSpan 2 spanStartEnd :: GHC.SrcSpan -> (SimpPos,SimpPos) ; spanStartEnd sspan = (getGhcLoc sspan,getGhcLocEnd sspan) -Call drawTreeEntry on the entire token cache -Call drawTreeEntry on the entire token cache &Neat 2-dimensional drawing of a tree. (Neat 2-dimensional drawing of a forest. "Represent a tree in a more concise/ pretty way !4Make a tree representing a particular set of tokens "4Make a tree representing a particular set of tokens $BSynchronise a located AST fragment to use a newly created SrcSpan  in the token tree. y     Updated forest, removed span The forest to update "The new span comes after this one Existing span for the tokens ,The new tokens belonging to the new SrcSpan *Unique SrcSpan allocated in the forest to $ identify this span in its position   TokenTree to be modified "Preceding location for new tokens New tokens to be added +updated TokenTree and SrcSpan location for ! the new tokens in the TokenTree   TokenTree to be modified "Preceding location for new tokens New tokens to be added /Declaration the tokens belong to, to be synced (updated TokenTree ,SrcSpan location for M -> (Tree Entry, GHC.SrcSpan,t) -- ^ updated TokenTree ,SrcSpan location for & the new tokens in the TokenTree, and  updated AST element   !"#$The AST (or fragment)  => t -- ^The AST (or fragment) &The SrcSpan created in the Tree Entry Existing token tree Updated AST and tokens / -> (t, Tree Entry) -- ^Updated AST and tokens ) syncAST (GHC.L _l t) sspan forest = (ast',forest') %&b,-.      !"#$%&b,.-  $   !" %&#s           !"#$%& None'/fetch the possibly modified tokens. Deprecated (fetch the final tokens ) fetch the pristine token stream *0Get the current tokens for a given GHC.SrcSpan. +6Get the current tokens preceding a given GHC.SrcSpan. ,1Replace a token occurring in a given GHC.SrcSpan -CReplace the tokens for a given GHC.SrcSpan, return new GHC.SrcSpan  delimiting new tokens .?Replace the tokens for a given GHC.SrcSpan, return GHC.SrcSpan  they are placed in /*Add tokens after a designated GHC.SrcSpan 0'Add tokens after a designated position 1>Add tokens after a designated GHC.SrcSpan, and update the AST  fragment to reflect it 2/Remove a GHC.SrcSpan and its associated tokens 3/Remove a GHC.SrcSpan and its associated tokens 4(Print the Token Tree for debug purposes 5-Print detailed Token Tree for debug purposes 6&Get the Token Tree for debug purposes $'()*+,-./0123456789:;<=>?@ABCDEFGH Old element  New element pretty printer !Add trailing newline if required Updates the RefactState I!Start and end pos of old element  New element pretty printer !Add trailing newline if required Updates the RefactState #'()*+,-./0123456789:;<=>?@ABCDEFGHI#()'89:;<=>?@,-*+./01237456ABCDEFHIG$'()*+,-./0123456789:;<=>?@ABCDEFGHI NoneaCRepresents the operation type we want to select on addItemsToImport' Used for addItemsToImport Used for addHiding K"Return True if any of the GHC.Name's appear in the given  syntax element L;Returns True is a syntax phrase, say a, is part of another  syntax phrase, say b. N3Return the binds that are directly enclosed in the  given syntax phrase. ) hsValBinds :: t -> [GHC.LHsBind GHC.Name] O5Replace the directly enclosed bind list by the given 5 bind list. Note: This function does not modify the  token stream. + replaceBinds :: t -> [GHC.LHsBind GHC.Name] -> t PBProcess the inscope relation returned from the parsing and module E analysis pass, and return a list of four-element tuples. Each tuple , contains an identifier name, the identifier's namespace info, the  identifier'/s defining module name and its qualifier name. DThe same identifier may have multiple entries in the result because B it may have different qualifiers. This makes it easier to decide C whether the identifier can be used unqualifiedly by just checking A whether there is an entry for it with the qualifier field being  Nothing. QAReturn True if the identifier is inscope and can be used without  a qualifier. RAReturn True if the identifier is inscope and can be used without > a qualifier. The identifier name string may have a qualifier  already = NOTE: may require qualification based on name clash with an  existing identifier. TShow a PName in a format like: pn(at row:r, col: c). WDefault expression. YAMake a new GHC.Name, using the Unique Int sequence stored in the  RefactState. [@Create a new name base on the old name. Suppose the old name is f, then  the new name would be like f_i where i is an integer. \@Return True if the current module is exported either by default 1 or by specifying the module name in the export. ]AReturn True if an identifier is exported by the module currently  being refactored. ^CReturn True if an identifier is explicitly exported by the module. _ECheck if the proposed new name will conflict with an existing export `ACollect the free and declared variables (in the GHC.Name format) D in a given syntax phrase t. In the result, the first list contains ? the free variables, and the second list contains the declared  variables.  Expects RenamedSource a The same as ` except that the returned % variables are in the String format. Experiment with GHC fvs stuff bExperiment with GHC fvs stuff eSame as f* except that the returned identifiers are  in String format. fBGiven syntax phrases e and t, if e occurs in t, then return those B variables which are declared in t and accessible to e, otherwise  return []. gAReturn True if the identifier is unqualifiedly used in the given  syntax phrase. : usedWithoutQualR :: GHC.Name -> GHC.ParsedSource -> Bool hh is different from ` in ! that: given an syntax phrase t, h returns not only E the declared variables that are visible from outside of t, but also B those declared variables that are visible to the main expression  inside t. ) NOTE: Expects to be given RenamedSource i The same as h$ except that the returned variables  are in the String format j!True if the name is a field name k!True if the name is a field name l%True if the name is a class instance mDCollect the identifiers (in PName format) in a given syntax phrase. .Get all the names in the given syntax element o=Return True if a string is a lexically valid variable name. p?Return True if a string is a lexically valid constructor name. q<Return True if a string is a lexically valid operator name. 5Returns True if a string lexically is an identifier. ) *This function should not be exported.* r,Return True if a PName is a toplevel PName. s)Return True if a PName is a local PName. t$Return True if a PName is a function/pattern name defined in t. u-Return True if a PName is a qualified PName. N AZ:NOTE: this tests the use instance, the underlying name may be qualified. / e.g. used name is zip, GHC.List.zip F NOTE2: not sure if this gives a meaningful result for a GHC.Name v>Return True if a declaration is a type signature declaration.  isTypeSig ::HsDeclP->Bool 9 isTypeSig (TiDecorate.Dec (HsTypeSig loc is c tp))=True w7Return True if a declaration is a function definition. y4Returns True if a declaration is a pattern binding. {=Return True if a declaration is a pattern binding which only  defines a variable value. |HReturn True if a declaration is a pattern binding but not a simple one. }*Return True if a declaration is a function/pattern definition. ~*Return True if a declaration is a function/pattern definition.  Find those declarations(function/pattern binding and type D signature) which define the specified PNames. incTypeSig indicates < whether the corresponding type signature will be included.  Find those declarations(function/pattern binding) which define ; the specified GHC.Names. incTypeSig indicates whether the 0 corresponding type signature will be included.  Find those declarations(function/pattern binding) which define ; the specified GHC.Names. incTypeSig indicates whether the 0 corresponding type signature will be included. 8Find those type signatures for the specified GHC.Names. ?Return True if syntax phrases t1 and t2 refer to the same one. Return True if the function/pattern binding defines the  specified identifier. AReturn True if the declaration defines the type signature of the  specified identifier. FReturn the list of identifiers (in PName format) defined by a function/pattern binding. @Find the identifier(in GHC.Name format) whose start position is > (row,col) in the file specified by the fileName, and returns  ' if such an identifier does not exist. CFind the identifier(in GHC.RdrName format) whose start position is > (row,col) in the file specified by the fileName, and returns  ' if such an identifier does not exist. ,Worker for both locToName and locToRdrName. E NOTE: provides for FunBind MatchGroups where only the first name is  retained in the AST 3Find all Located Names in the given Syntax phrase. @Find the identifier with the given name. This looks through the C given syntax phrase for the first GHC.Name which matches. Because > it is Renamed source, the GHC.Name will include its defining 5 location. Returns Nothing if the name is not found. |Add identifiers to the export list of a module. If the second argument is like: Just p, then do the adding only if p occurs  in the export list, and the new identifiers are added right after p in the export list. Otherwise the new identifiers are add  to the beginning of the export list. In the case that the export list is emport, then if the third argument is True, then create S an explict export list to contain only the new identifiers, otherwise do nothing. `Remove ImportDecl from the imports list, commonly returned from a RenamedSource type, so it can  be further processed. :rmPreludeImports :: [GHC.Located (GHC.ImportDecl GHC.Name)]* -> [GHC.Located (GHC.ImportDecl GHC.Name)] <Make a new set of tokens, originating at (0,0), for a given % declaration and optional signature. @ NOTE: This function returns tokens originating at (0,0), to be . stitched in at the right place by TokenUtils AAdding a declaration to the declaration list of the given syntax # phrase(so far only adding function/pattern binding has been B tested). If the second argument is Nothing, then the declaration C will be added to the beginning of the declaration list, but after - the data type declarations is there is any. ATake a list of strings and return a list with the longest prefix  of spaces removed <add items to the hiding list of an import declaration which  imports the specified module.  9Creates a new entity for hiding a name in an ImportDecl. kAdd identifiers (given by the third argument) to the explicit entity list in the declaration importing the w specified module name. This function does nothing if the import declaration does not have an explicit entity list. !kAdd identifiers (given by the third argument) to the explicit entity list in the declaration importing the b specified module name. If the ImportType argument is Hide, then the items will be added to the hiding l list. If it is Import, they will be added to the explicit import entries. This function does nothing if Z the import declaration does not have an explicit entity list and ImportType is Import. "AAdd tokens corresponding to the new parameters to the end of the  syntax element provided MRemove those specified items from the entity list in the import declaration. -Remove the specified entities from the module'Cs exports. The entities can be specified in either of two formats: z i.e. either specify the module names and identifier names to be removed, so just given the exact AST for these entities. Duplicate a function/-pattern binding declaration under a new name > right after the original one. Also updates the token stream. =Remove the declaration (and the type signature is the second ? parameter is True) that defines the given identifier from the  declaration list.  Remove multiple type signatures ;Remove the type signature that defines the given identifier's ! type from the declaration list. LRemove the qualifier from the given identifiers in the given syntax phrase. IReplace all occurences of a top level GHC.Name with a qualified version. >Rename each occurrences of the identifier in the given syntax ? phrase with the new name. If the Bool parameter is True, then E modify both the AST and the token stream, otherwise only modify the  AST. E TODO: the syntax phrase is required to be GHC.Located, not sure how = to specify this without breaking the everywhereMStaged call #>Rename each occurrences of the identifier in the given syntax ? phrase with the new name. If the Bool parameter is True, then E modify both the AST and the token stream, otherwise only modify the  AST. E TODO: the syntax phrase is required to be GHC.Located, not sure how = to specify this without breaking the everywhereMStaged call Create a new name token. If useQual then use the qualified  name, if it exists. B The end position is not changed, so the eventual realignment can 4 know what the difference in length in the token is QCheck whether the specified identifier is declared in the given syntax phrase t, [ if so, rename the identifier by creating a new name automatically. If the Bool parameter R is True, the token stream will be modified, otherwise only the AST is modified. <Show a list of entities, the parameter f is a function that $ specifies how to format an entity. Return the identifier's defining location.  defineLoc::PNT->SrcLoc Return the identifier's source location.  useLoc::PNT->SrcLoc 6Return True if the identifier is used in the RHS if a  function/pattern binding. AReturn True if the identifier occurs in the given syntax phrase. 5Find all occurrences with location of the given name $@Find all locations where names occur in the given syntax phrase AReturn True if the identifier occurs in the given syntax phrase. MReturn True if any of the specified PNames ocuur in the given syntax phrase. >Given the syntax phrase, find the largest-leftmost expression E contained in the region specified by the start and end position, if  found. BIf an expression consists of only one identifier then return this F identifier in the GHC.Name format, otherwise return the default Name >If a pattern consists of only one identifier then return this & identifier, otherwise return Nothing  Compose a pattern from a pName. /Get the signature and tokens for a declaration %BNormalise a set of tokens to start at the offset of the first one Remove at most offset* whitespaces from each line in the tokens & Get signature for a declaration JK'LMNO(PThe inscope relation .  The result QThe identifier name. The inscope relation  The result. RThe identifier name. ,Existing name, to be excluded from test, if  known  The result. SThe identifier name.  The result. TUVWXYZ[ The old name 0The set of names which the new name cannot take The posfix value  The result \The module name The AST of the module  The result ]^The identifier The AST of the module  The result _The original name  The new name The identity of the module The AST of the module  The result `)abcdefghijklmnopqrstu*vwxyz{|}~+,-The specified identifiers. A collection of declarations. *True means to include the type signature. 7True means to look at the local declarations as well.  The result. The specified identifiers. A collection of declarations. *True means to include the type signature. 7True means to look at the local declarations as well.  The result. The specified identifiers. A collection of declarations.  The result. The specified identifiers. A collection of declarations.  The result. The file name The row and column number The syntax phrase  The result The file name The row and column number The syntax phrase  The result The file name The row and column number The syntax phrase  The result The syntax phrase  The result The name to find The syntax phrase  The result .The AST to be updated &If this is Just, then the declaration  will be added right after this  identifier's definition. 6The declaration with optional signatures to be added, 4 in both AST and Token stream format (optional). If 2 signature and tokens provided, the tokens should  include the signature too  True means the declaration is a  toplevel declaration. The imported module name The current module The items to be added 'The result (with token stream updated)  The imported module name The current module The items to be added 8 ->Maybe GHC.Name -- ^ The condition identifier. 'The result (with token stream updated) !The imported module name The current module The items to be added 8 ->Maybe GHC.Name -- ^ The condition identifier. IWhether to hide the names or import them. Uses special data for clarity. 'The result (with token stream updated) 4A declaration list where the function is defined and/ or used. The function name. The parameters to be added.  Modify the token stream or not.  The result. "The declaration list Any signatures are in here 4The identifier whose definition is to be duplicated "The new name (possibly qualified)  The result 2The identifier whose definition is to be removed. )True means including the type signature. The declaration list. The result and the removed  declaration, with SrcSpans ! adjusted to reflect the stashed ! tokens and the possibly removed  siganture 9The identifiers whose type signatures are to be removed. The declarations ,The result and removed signatures, if there  were any 6The identifier whose type signature is to be removed. The declarations +The result and removed signature, if there  was one The identifiers. The syntax phrase.  The result. The identifier to be renamed. +The new name, including possible qualifier /True means modifying the token stream as well. &True means use the qualified form for  the new name. The syntax phrase #The identifier to be renamed. +The new name, including possible qualifier /True means modifying the token stream as well. &True means use the qualified form for  the new name. The syntax phrase 1True means modfiying the token stream as well. The identifier. The syntax phrase.  The result. $The start position. The end position. The syntax phrase.  The result. /%&0123456789:;<=>?@ABCDEFGHIJKLMNOPQlJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~lPQRS]^\jklmMNO`abcdfehiopqrsutvwxyz{|}~gLJKnTUVWXY[Z_JK'LMNO(PQRSTUVWXYZ[\]^_`)abcdefghijklmnopqrstu*vwxyz{|}~+,-. !"#$/%&0123456789:;<=>?@ABCDEFGHIJKLMNOPQ None?Update the occurrence of one syntax phrase in a given scope by ( another syntax phrase of the same type AThe result of a refactoring is the file, a flag as to whether it = was modified, the updated token stream, and the updated AST From file name to module name. @Extract the module name from the parsed source, if there is one =Load a module graph into the GHC session, starting from main BOnce the module graph has been loaded, load the given module into  the RefactGhc monad AIn the existing GHC session, put the requested TypeCheckedModule  into the RefactGhc monad .Parse a single source file into a GHC session @Manage a whole refactor session. Initialise the monad, load the : whole project if required, and then apply the individual 2 refactorings, and write out the resulting files. ?It is intended that this forms the umbrella function, in which  applyRefac is called BApply a refactoring (or part of a refactoring) to a single module =Returns True if any of the results has its modified flag set R*Write refactored program source to files. @Return the client modules and file names. The client modules of ? module, say m, are those modules which directly or indirectly  import module m. ?Return the server module and file names. The server modules of C module, say m, are those modules which are directly or indirectly E imported by module m. This can only be called in a live GHC session <Return True if the given module name exists in the project. <isAnExistingMod::( ) =>ModuleName->PFE0MT n i ds ext m Bool DGet the current module graph, provided we are in a live GHC session !S!The syntax phrase to be updated. The new syntax phrase. /The contex where the old syntax phrase occurs.  The result. TIdentifies the surrounding  project The computation doing the  refactoring. Normally created  via  The refactoring !where to get the module and toks UVRWXYZ[\]STUVRWXYZ[\] None>This refactoring duplicates a definition (function binding or G simple pattern binding) at the same level with a new name provided by 3 the user. The new name should not cause name clash/ capture. ^5Find the the new definition name in GHC.Name format. _9Do refactoring in the client module. That is to hide the E identifer in the import declaration if it will cause any problem in  the client module. `:get the module name or alias name by which the duplicated , definition will be imported automatically. abc^_d`abc^_d`None #Lift a definition to the top level 4Move a definition one level up from where it is now !Move a definition one level down eGet the subset of pns) that need to be renamed before lifting. fCDo refactoring in the client module. that is to hide the identifer ? in the import declaration if it will cause any problem in the  client module. g?Test whether an identifier defined in the modules specified by  names% will be exported by current module. hAget the module name or alias name by which the lifted identifier ! will be imported automatically. & TODO: maybe move this into TypeUtils O willBeUnQualImportedBy::HsName.ModuleName->HsModuleP->Maybe [HsName.ModuleName] iget the subset of pns', which need to be hided in the import  declaration in module j B Note: these are newly exported from the module, so we cannot use ' the GHC name resolution i nthis case. k.Do refactoring in the client module, that is: = a) Check whether the identifier is used in the module body > b) If the identifier is not used but is hided by the import 2 declaration, then remove it from the hiding. l/substitute an old expression by new expression m%return True if pn is a local function/ pattern name nCDivide a declaration list into three parts (before, parent, after)  according to the PNT, where parent is the first decl containing  the PNT, before are those decls before parent and after are  those decls after parent. opqrstuvwThe syntax element to update &If specified, add defn after this one "The first one is the decl to move -The signatures to remove. May be multiple if # decl being moved has a patbind.  True if moving to the top level 1The updated syntax element (and tokens in monad) xeyfghiz{|Declared names in parent }k~(The (list?) function name being demoted 2The RHS of the place to receive the demoted decls ;Binds of original top level entiity, including src and dst The decls being demoted !Signatures being demoted, if any Tokens if provided lmnorqpstuvwxeyfghiz{|}k~lmnNoneRename the given identifier. Body of the refactoring AActually do the renaming, split into the various things that can 2 be renamed. Returns True if the name is exported NoneNone.Convert an if expression to a case expression  !"#$%&'()*+,-./01234567889:;<=>=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                          ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 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 [ \ ] ^ _ ` 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 { | } ~                                                                                                                   ! " # $ % & ' ( ) * +,-. / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 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 [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u vwxyrz,{|}~sss HaRe-0.7.0.20Language.Haskell.Refact.Utils.RenamedSourceUtils,Language.Haskell.Refact.Utils.GhcModuleGraph%Language.Haskell.Refact.Utils.TypeSyn0Language.Haskell.Refact.Utils.GhcVersionSpecific-Language.Haskell.Refact.Utils.TokenUtilsTypes#Language.Haskell.Refact.Utils.Monad&Language.Haskell.Refact.Utils.GhcUtils&Language.Haskell.Refact.Utils.LocUtils(Language.Haskell.Refact.Utils.TokenUtils,Language.Haskell.Refact.Utils.MonadFunctions'Language.Haskell.Refact.Utils.TypeUtilsLanguage.Haskell.Refact.UtilsLanguage.Haskell.Refact.DupDefLanguage.Haskell.Refact.MoveDef Language.Haskell.Refact.Renaming Language.Haskell.Refact.SwapArgsLanguage.Haskell.Refact.Case Paths_HaRegetFreeVariablesgetModulesAsGraphsummaryNodeSummary HsModulePPNamePNHsNameExportPoscharlinecolumnPosTokenSimpPosInScopesHsDeclsPHsDeclPHsPatPHsExpPgheadglastgtail gfromJustshowGhc prettyprint prettyprint2lexStringToRichTokensgetDataConstructors setGhcContext TokenCacheTKtkCache tkLastTreeIdTreeIdTId ForestSpan ForestPos ForestLineflSpanLengthChangedflTreeSelectorflInsertVersionflLineEntryDeletedmainTid RefactGhc StateStorage StorageSig StorageBind StorageNone ParseResult RefactStateRefSt rsSettings rsUniqStatersFlags rsStoragersModule RefactFlagsRefFlagsrsDone RefactModuleRefModrsTypecheckedModrsOrigTokenStream rsTokenCachersStreamModified RefactStashIdStashRefactSettingsRefSet rsetGhcOptsrsetImportPathsrsetExpandSplice rsetMainFile rsetSandboxrsetCheckTokenUtilsInvariantrsetVerboseLevel VerboseLevelOffNormalDebugdefaultSettings logSettingsinitGhcSession runRefactGhcgetRefacSettingseverythingButStagedsomethingStagedsomewhereMStagedsomewhereMStagedBueverywhereMStagedeverywhereMStaged'everywhereStagedeverywhereStaged'checkItemRenamer listifyStaged full_tdTUGhc stop_tdTUGhc allTUGhc' once_tdTPGhc once_buTPGhconeTPGhcallTUGhccheckItemStage'checkItemRenamer'zeverywhereStaged zopenStagedzsomewhereStagedtransZtransZMcheckZipperStagedupUntil findAbove zopenStaged'ztransformStagedMshowToks unmodifiedmodifiedsimpPos0 nullSrcSpanisWhitenotWhiteisMultiLineCommentisOpenSquareBracketisCloseSquareBracketisInisCommaisBar endsWithNewLnstartsWithNewLnhasNewLncompressPreNewLnscompressEndNewLnsprettyprintPatListtokenise basicTokenise addLocInfolengthOfLastLinegetToksreplaceTokNoReAlign matchTokenPos getLineOffset deleteToks doRmWhiteswhiteSpaceTokenssrcLocsgetBiggestStartEndLoc getAllSrcLocsextendBackwardsextendForwardsstartEndLocIncFowCommenttokenCol tokenColEndtokenRowtokenPos tokenPosEndtokenConincreaseSrcSpan getGhcLoc getGhcLocEndgetLocatedStart getLocatedEndgetStartEndLocstartEndLocGhcrealSrcLocFromTokrealSrcLocEndTokfileNameFromTok splitToks emptyList nonEmptyListstartEndLocIncCommentsstartEndLocIncComments'divideComments isWhiteSpace notWhiteSpace isDoubleColon isCommentisEmpty isWhereOrLetisWhereisLetisElseisThen getSrcSpangetIndentOffset splitOnNewLntokenLen newLnToken newLinesTokengroupTokensByLinemonotonicLineToksreSequenceToksmkToken mkZeroTokenaddOffsetToToks markTokenisMarked Positioning PlaceIndent PlaceOffset PlaceAbsCol PlaceAbsolute PlaceAdjacent ReversedToksRT reverseToks unReverseToks reversedToksghcLineToForestLineforestLineToGhcLineforestSpanToSrcSpanforestSpanVersionsforestSpanVersionSetforestSpanVersionNotSetforestPosVersionSetforestPosVersionNotSetforestSpanLenChangedforestSpanToSimpPosforestSpanToGhcPossimpPosToForestSpansrcPosToSimpPosnullSpannullPosshowForestSpaninsertForestLineInSrcSpaninsertVersionsInSrcSpaninsertLenChangedInSrcSpansrcSpanToForestSpantreeIdFromForestSpaninitTokenCachereplaceTokenInCacheputToksInCacheremoveToksFromCachegetTreeFromCachereplaceTreeInCachesyncAstToLatestCache getTokensForgetTokensBeforereplaceTokenForSrcSpanupdateTokensForSrcSpan getSrcSpanFor insertSrcSpan doSplitTree splitSubToks containsStartcontainsMiddle containsEnd splitSubtree removeSrcSpan calcEndGapretrieveTokensFinalretrieveTokensInterimretrieveTokens'deleteGapsToksdeleteGapsToks'retrievePrevLineToksstripForestLines reAlignMarkedreAlignOneLine reAlignToksaddNewSrcSpanAndToksAfterplaceToksForSpanaddToksAfterSrcSpan limitPrevToksaddDeclToksAfterSrcSpan reIndentToksnonCommentSpan posToSrcSpanposToSrcSpanTokinsertNodeAfteropenZipperToNode spanContainsopenZipperToSpansplitForestOnSpan invariantOk invariant treeStartEnd spanStartEnd showForestdrawTokenCachedrawTokenCacheDetailed drawTreeEntrydrawForestEntry drawEntryshowTreemkTreeFromTokensmkTreeFromSpanTokensghcSpanStartEndsyncAST showSrcSpan showSrcSpanF fetchToksfetchToksFinal fetchOrigToksgetToksForSpangetToksBeforeSpan replaceTokenputToksForSpan putToksForPosputToksAfterSpanputToksAfterPosputDeclToksAfterSpanremoveToksForSpanremoveToksForPos drawTokenTreedrawTokenTreeDetailed getTokenTreesyncDeclToLatestStashgetTypecheckedModulegetRefactStreamModifiedgetRefactInscopesgetRefactRenamedputRefactRenamedgetRefactParsedputParsedModuleclearParsedModulegetRefactFileName getRefactDone setRefactDoneclearRefactDonesetStateStoragegetStateStoragelogminitRefactModule updateToksupdateToksWithPos UsedByRhs usedByRhs findEntity HsValBinds hsValBindsreplaceValBinds inScopeInfoisInScopeAndUnqualifiedisInScopeAndUnqualifiedGhc inScopeNames showPNwithLoc defaultPN defaultName defaultExp mkRdrName mkNewGhcNamemkNewToplevelName mkNewName modIsExported isExportedisExplicitlyExportedcauseNameClashInExportshsFreeAndDeclaredPNshsFreeAndDeclaredNamesgetFvs getFreeVarsgetDeclaredVarshsVisibleNames hsVisiblePNsusedWithoutQualRhsFDsFromInsidehsFDNamesFromInside isFieldName isClassNameisInstanceNamehsPNs getModuleisVarIdisConId isOperator isTopLevelPN isLocalPNisFunOrPatName isQualifiedPN isTypeSig isFunBindP isFunBindR isPatBindP isPatBindRisSimplePatBindisComplexPatBindisFunOrPatBindPisFunOrPatBindRhsBinds replaceBinds isDeclaredIn findEntity' definingDeclsdefiningDeclsNamesdefiningDeclsNames'definingSigsNamessameOccurrencedefinesdefinesPdefinesTypeSig definedPNssameBind locToName locToRdrNameallNamesgetName addImportDecladdDeclstripLeadingSpaces addHidingaddItemsToImportaddParamsToDeclsaddActualParamsToRhs duplicateDeclrmDecl rmTypeSigs rmTypeSig rmQualifierqualifyToplevelNamerenamePN newNameTokautoRenameLocalVar showEntities isMainModule defineLocuseLoc isUsedInRhsfindPNTfindAllNameOccurencesfindPNfindPNslocToExpghcToPNlghcToPN expToName nameToStringpatToPNTpNtoPatgetDeclAndToks getSigAndToks removeOffsetupdate RefacSourceRSAlreadyLoadedRSModRSFileApplyRefacResultpwdfileNameToModName getModuleNameloadModuleGraphGhc getModuleGhcgetModuleDetailsparseSourceFileGhcrunRefacSession applyRefac refactDonefileNameFromModSummaryclientModsAndFilesserverModsAndFilesgetCurrentModuleGraphsortCurrentModuleGraph duplicateDefliftToTopLevel liftOneLeveldemoterenameswapArgsifToCasecatchIOversionbindirlibdirdatadir libexecdir sysconfdir getBinDir getLibDir getDataDir getLibexecDir getSysconfDirgetDataFileNameNodeMapNodeKey SummaryNodesummaryNodeKeymoduleGraphNodes home_impsms_home_srcimps ms_home_imps$fShowNameSpace$fOutputableNameSpace$fShowForestLine$fEqForestLine$fMonadPlusGhcT$fMonadTransGhcT$fMonadStateRefactStateGhcT$fExceptionMonadStateT$fMonadIOStateT $fMonadIOGhcT$fShowStateStoragecheckItemStageeverythingStagedlastNonSpaceToken adjustLayout tokenFileMark defaultTokenreplaceTabBySpacesgoMonotonicLineToksonSameLn$fShowGenLocatedforestSpanAstVersionsforestSpanLenChangedFlagsforestPosAstVersionSettreeIdIntoForestSpan mergeDeletes prettyshowforestLineMaskforestVersionMaskforestTreeMaskforestLenChangedMaskforestVersionShiftforestTreeShiftforestPosLenChangedforestSpanStart forestSpanEndinsertVersionsInForestSpanforestSpanFromEntrytreeIdIntoTreestash putTidInTreemkTreeListFromTokensgoDeleteGapsToksgoDeleteGapsToks'getChildrenAsZ prettyToksaddOffsetToSpan$fOrdForestLine timeStamp ImportTypeImportHide getFvsAllhsNamessisIdbase Data.MaybeNothing locToName'rmPreludeImports makeNewToksmkNewEntaddItemsToImport'addFormalParamsrenamePNworker findAllNamesremoveToksOffsetgetSig FindEntitydebughsFreeAndDeclaredPNs'isQualifiedPN'getValBindSigs emptyValBinds unionBinds isEmptyGroupgetToksForDecl$fUsedByRhsStmtLR$fUsedByRhsHsExpr$fUsedByRhsGenLocated$fUsedByRhsHsBindLR $fUsedByRhs[]$fUsedByRhsMatch$fUsedByRhsHsValBindsLR$fUsedByRhsBag$fUsedByRhs(,,,)$fFindEntityGenLocated$fFindEntityGenLocated0$fFindEntityGenLocated1$fFindEntityGenLocated2$fFindEntityName$fHsValBindsGenLocated$fHsValBinds[]$fHsValBindsGenLocated0$fHsValBinds[]0$fHsValBindsGenLocated1$fHsValBinds[]1$fHsValBindsGenLocated2$fHsValBindsBag$fHsValBindsStmtLR$fHsValBindsHsExpr$fHsValBindsHsBindLR$fHsValBindsMatch$fHsValBindsGenLocated3$fHsValBinds[]2$fHsValBindsMatchGroup$fHsValBindsGRHSs$fHsValBindsHsLocalBindsLR$fHsValBindsHsGroup$fHsValBindsHsValBindsLR$fHsValBinds(,,,)writeRefactoredFilesUpdate getExports modifiedFiles getDynFlagsbypassGHCBug7351mycomp$fShowModuleName$fUpdateGenLocatedt$fUpdateGenLocatedt0$fUpdateGenLocatedt1$fUpdateGenLocatedt2 findNewPNamerefactorInClientModwillBeUnQualImportedBycomp doDuplicatingreallyDoDuplicatingdoDuplicatingClientpnsNeedRenamingliftingInClientModwillBeExportedByClientModnamesNeedToBeHidedGHC.RealmoddemotingInClientModreplaceExpWithUpdToksisLocalFunOrPatName divideDecls DirectionDown UpOneLevel UptoTopLevelcompLiftToTopLevelcompLiftOneLevel compDemoteliftToTopLevel' moveDecl1askRenamingMsgaddParamsToParent liftOneLevel'liftedToTopLeveladdParamsToParentAndLiftedDecldemote'doDemotingInClientMod doDemoting doDemoting' foldParams doRenamingrenameTopLevelVarNamerenameInClientModcauseAmbiguityInExportsisValidNewNamedoSwap reallyDoSwapdoIfToCaseInternalreallyDoIfToCaseifToCaseTransform