úÎJôH     (Internals for the Data.QuadTree library.(c) Ashley Moni, 2015BSD3$Ashley Moni <ashley.moni1@gmail.com>StableSafeIN-Each ! is a tuple of an element from a  and the  it subtends.6Rectangular area, represented by a tuple of four Ints.<They correspond to (X floor, Y floor, X ceiling, Y ceiling).MThe co-ordinates are inclusive of all the rows and columns in all four Ints.regionArea (x, y, x, y) == 1!The internal data structure of a .Each > consists of either a terminating Leaf node, or four further s.The eponymous data type.Ž is itself a wrapper around an internal tree structure along with spatial metadata about the boundaries and depth of the 2D area it maps to.)Tuple corresponds to (X, Y) co-ordinates.Lens for the top left  of a node.Lens for the top right  of a node.Lens for the bottom left  of a node.Lens for the bottom right  of a node.*Lens for a terminate leaf value of a node.3Lens to zoom into the internal data structure of a +, lensing past the metadata to reveal the  inside.[Unsafe sanity test lens that makes sure a given location index exists within the relevant .ALens for accessing and manipulating data at a specific location./Getter for the value at a given location for a ./Setter for the value at a given location for a ."This automatically compresses the ' nodes if possible with the new value.)Modifies value at a given location for a ."This automatically compresses the ' nodes if possible with the new value. Checks if a  is outside the boundaries of a . Dimensions of a , as an Int pair. AAdd offsets to a location index for the purpose of querying the  's true reference frame.!Offsets added to a T 's true reference frame to reference elements in the centralized width and height."Merge  into a leaf node if possible.#)Test if all elements in a list are equal.$Apply a function to a  s internal . #Cleanup function for use after any .When elements of a  are modified by  (or the _ lens), it automatically compresses identical adjacent nodes into larger ones. This keeps the " from bloating over constant use.- does not do this. If you wish to treat the  as a R, you should compose this function after to collapse it down to its minimum size. Example:    $  fn tree ; This particular example is reified in the function below. tmap is simply  with   applied after.'tmap fn tree == fuseTree $ fmap fn tree%Foldr elements within a  , by first decomposing it into As and then decomposing those into lists of identical data values. Takes a list of Ts and then decomposes them into a list of all their elements, properly weighted by  size. Returns a list of s. The block equivalent of . Decomposes a  into its constituent s, before folding a % consuming function over all of them.&The region denoting an entire .' The boundary  of the internal  's true reference frame.() that's an intersection between two othe s.>Simple helper function that lets you calculate the area of a , usually for   purposes.&Does the region contain this location? s a list of the  's elements.)s a list of the  's elements. s a list of the s of a .)s a list of the s of a .Constructor that generates a F of the given dimensions, with all cells filled with a default value.*KFind the smallest tree depth that would encompass a given width and height.4Generates a newline delimited string representing a  as a 2D block of characters.Note that despite the word +& in the function name, this does not   the >. It pretty prints it. The name is simply a mnemonic for its  -> String behaviour.As  above, but also prints it.,s are -1s. -- You can fmap all their recursive leaf node..s are /L, though the traversal path is a complex recursive enumeration of internal 2s. Don't use folds that aren't ordering agnostic.0s are -*s, and their elements can be fmapped over.41234567 (Length, Width) !"#$ % &'((Length, Width)Initial element to fill**Function to generate characters for each  element.*Function to generate characters for each  element.,.011234567 !"#$ % &'(*-1234567 !"#$ % &'(*,.0#Region quadtrees with lens support.(c) Ashley Moni, 2015BSD3$Ashley Moni <ashley.moni1@gmail.com>StableSafeIN    8  !"#$%&'()*+,-./01234567896: ;6<=6>?@ABCDEFGQuadT_Ed1I5Emlqru1fAGCIJT3am Data.QuadTreeData.QuadTree.Internal Control.MonadfmapFunctor Data.FoldabletoList Data.List replicatefilterTextshowTileRegionQuadTreeLocation atLocation getLocation setLocation mapLocation outOfBoundstreeDimensionsfuseTreetmapexpandtile foldTiles regionAreainRegion filterTree sortTreeBy filterTiles sortTilesBymakeTreeshowTree printTreeQuadrant_a_b_c_d_leaf _wrappedTreeverifyLocation offsetIndexoffsetsfuseallEqualonQuadsfoldTree treeRegion boundariesregionIntersectionbase Data.OldListsortBy smallestDepthGHC.Show$fFunctorQuadrantGHC.Base$fFoldableQuadTreeFoldable$fFunctorQuadTreeLeafNodeWrapper wrappedTree treeLength treeWidth treeDepth