simtreelo-0.1.1.2: Loader for data organized in a tree

LicenseGPL-3
Maintainermarcelogmillani@gmail.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

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

Synopsis

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

toString :: [Tree [Char]] -> [Char] -> [Char] Source #

Transforms the forest into a string with the Simtreelo format

merge :: Eq a => [Tree a] -> Tree a -> [Tree a] Source #

Merges a tree into a forest, using available nodes when possible.

| Every node must have a unique label