Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- readDataFile :: String -> IO String
- unfold :: (a -> b -> ([a], b)) -> b -> [a] -> [a]
Documentation
readDataFile :: String -> IO String #
The readDataFile
function reads the contents of a file in the data directory as a string.
:: (a -> b -> ([a], b)) | A function from an element and accumulator to a tuple of list of children elements and updated accumulator |
-> b | The initial accumulator |
-> [a] | The initial set of elements |
-> [a] | The results |
The unfold
function is like unfoldr
generalized to a tree, or
like an accumulating breadth-first traversal of unfoldTree
.
In the special case where each node of the tree has at most one child,
unfold
will build the same list that unfoldr
would.
unfoldr f b0 == unfold (\_ b -> maybe ([], b) (\(a, b') -> ([a], b')) (f b)) b0 [undefined]
In the special case where there is no accumulator being passed through every
level built, unfold
will produce the same list that a breadth-first
traversal of unfoldTree
would.
concat (levels (foldTree f b0)) == map fst (unfold (\(_, bs) _ -> (map f bs, ())) () [f b0])