packages feed

simtreelo 0.1.0.3 → 0.1.1.0

raw patch · 2 files changed

+31/−2 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Simtreelo: merge :: Eq a => [Tree a] -> Tree a -> [Tree a]
+ Data.Simtreelo: toString :: [Tree [Char]] -> [Char] -> [Char]
+ Data.Simtreelo: write :: [Tree [Char]] -> [Char] -> [Char] -> FilePath -> IO ()

Files

Data/Simtreelo.hs view
@@ -36,9 +36,38 @@ >    Edward  -}-module Data.Simtreelo(loadString, loadFile) where+module Data.Simtreelo(loadString, loadFile, write, toString, merge) where  import Data.Tree++-- | Merges a tree into a forest, using available nodes when possible.+--+-- | Every node must have a unique label+merge [] tree = [ tree ]+merge (fh:fr) tree+  | rootLabel fh == rootLabel tree = Node{rootLabel = rootLabel tree, subForest = mergeForest (subForest fh) (subForest tree)} : fr+  | otherwise = fh : merge fr tree++-- | Merges two forests into one, joining duplicate nodes when possible+--+-- | Every node must have a unique label++mergeForest fa fb = foldl merge fa fb+++-- | Writes a forest into a file using the Simtreelo format+write forest comment indent file =+  let contents = comment ++ "\n" ++ toString forest indent in+  writeFile file contents++-- | Transforms the forest into a string with the Simtreelo format+toString forest indent = concat $ map ( toString' indent 0) forest+toString' indent depth tree =+  indentation ++ (rootLabel tree) ++ "\n" ++ children+  where+    indentation = concat $ take depth $ repeat indent+    children = concat $ map (toString' indent (depth + 1) ) $ subForest tree+    -- | The input 'String' must be organized in such a way that every child is one indentation lower than its parent, and all siblings have the same indentation. --
simtreelo.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.1.0.3+version:             0.1.1.0  -- A short (one-line) description of the package. synopsis:            Loader for data organized in a tree