úÎH½F“"      !Pportable Provides a simple data structure mirroring a directory tree on the  experimental-Brandon Simmons <brandon.m.simmons@gmail.com> Safe-Inferedan element in a FilePath: Ea simple wrapper to hold a base directory name, which can be either H an absolute or relative path. This lets us give the DirTree a context, M while still letting us store only directory and file NAMES (not full paths) 0 in the DirTree. (uses an infix constructor; don' t be scared) Gthe String in the name field is always a file name, never a full path. N The free type variable is used in the File constructor and can hold Handles,  Strings representing a file'.s contents or anything else you can think of. H We catch any IO errors in the Failed constructor. an Exception can be  converted to a String with ". Kbuild an AnchoredDirTree, given the path to a directory, opening the files  using readFile.  Uses  1 internally and has the effect of traversing the ! entire directory structure. See   for lazy production  of a DirTree structure. :same as readDirectory but allows us to, for example, use 6 ByteString.readFile to return a tree of ByteStrings. A lazy version of  # that does IO operations as needed - i.e. as the tree is traversed in pure code.  NOTE:F This function uses unsafePerformIO under the hood. I believe our use B here is safe, but this function is experimental in this release: Fwrite a DirTree of strings to disk. Clobbers files of the same name.  Doesn'?t affect files in the directories (if any already exist) with D different names. Returns a new AnchoredDirTree where failures were  lifted into a  constructor: Jwrites the directory structure to disk and uses the provided function to  write the contents of Files0 to disk. The return value of the function will  become the new 3 of the returned, where IO errors at each node are  replaced with 4 constructors. The returned tree can be compared to 9 the passed tree to see what operations, if any, failed: 4a simple application of readDirectoryWith openFile: Jbuilds a DirTree from the contents of the directory passed to it, saving O the base directory in the Anchored* wrapper. Errors are caught in the tree in  the Failed constructor. The + fields initially are populated with full * paths to the files they are abstracting.  identical to 1 but does directory reading IO lazily as needed: ,True if any Failed constructors in the tree 5True if there are no Failed constructors in the tree returns true if argument is a  constructor: returns a list of  constructors only: <maps a function to convert Failed DirTrees to Files or Dirs @Recursively sort a directory tree according to the Ord instance Recursively sort a tree as in # but ignore the file contents of a  File constructor JTests equality of two trees, ignoring their free variable portion. Can be F used to check if any files have been added or deleted, for instance. )a compare function that ignores the free file type variable: $strips away base directory wrapper: Happlies the predicate to each constructor in the tree, removing it (and I its children, of course) when the predicate returns False. The topmost ' constructor will always be preserved:  Flattens a 1 into a (never empty) list of tree constructors.   constructors will have [] as their : LAllows for a function on a bare DirTree to be applied to an AnchoredDirTree B within a Functor. Very similar to and useful in combination with #: Ktuple up the complete filename with the File contents, by building up the O path, trie-style, from the root. The filepath will be relative to the current  directory. ' This allows us to, for example, mapM_ 'uncurry writeFile' over a DirTree of  strings, although  does a better job of this. !Iwrites the directory structure (not files) of a DirTree to the anchored K directory. Returns a structure identical to the supplied tree with errors  replaced by  constructors: $#First compare constructors: Failed < Dir < File...  Then compare  ... ) Then compare free variable parameter of  constructors %HTwo DirTrees are equal if they have the same constructor, the same name  (and in the case of s) their sorted  are equal: (  !&'()$%"  !$    !      !&'()$%*      !"#$%&$'()*+,-./directory-tree-0.10.1System.Directory.TreeFileNameAnchoredDirTree:/DirTreeFilefileDircontentsFailednameerr readDirectoryreadDirectoryWithreadDirectoryWithLwriteDirectorywriteDirectoryWith openDirectorybuildbuildL anyFailed successfulfailedfailures failedMapsortDir sortDirShape equalShapecomparingShapefree filterDir flattenDirzipPaths writeJustDirsbaseGHC.Showshow Data.Functor<$> $fOrdDirTree $fEqDirTree$fFunctorAnchoredDirTree$fTraversableDirTree$fFoldableDirTree$fFunctorDirTree