License | GPL-3 |
---|---|
Maintainer | marcelogmillani@gmail.com |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
Data.Simtreelo
Description
This library loads trees that are described through text. In order to preserve readability, the hierarchy of the tree is give exclusively by the indentation level, which can be any number of spaces or tabs, as long as coherence is kept.
The first line of the file describes the comment pattern. Every line contains one node of the tree, and the parent is determined by the indentation level, which is given by tabs or spaces. Whitespaces on the right of names are ignored. If the first line is empty, comments will be disabled.
Example file:
-- A node -- this is a comment Child -- indentation is given by 2 spaces here Brother Debora Edward
Documentation
loadString :: String -> Either [Char] [Tree [Char]] Source #
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.
The String
used for indentation is inferred from the first indentation depth
The entire first line (except the newline character) represents the beginning of a comment
Returns the first error message on failure, or the Tree
on success
loadFile :: FilePath -> IO (Either [Char] [Tree [Char]]) Source #
Just applies loadString to the contents of the given file
write :: [Tree [Char]] -> [Char] -> [Char] -> FilePath -> IO () Source #
Writes a forest into a file using the Simtreelo format