Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Helper functions and types that can be useful in more than one place.
Synopsis
- type ParentList a = [(a, Maybe a)]
- readForest :: Ord a => ParentList a -> Forest a
- type CountingT m = StateT Int m
- next :: Monad m => CountingT m Int
- runCountingT :: Monad m => CountingT m a -> Int -> m a
- storeAsXlsx :: (DefaultOrdered a, ToNamedRecord a) => FilePath -> [a] -> IO ()
- loadFromXlsx :: FromNamedRecord a => FilePath -> IO (Either String [a])
- libreOfficeIsRunning :: IO Bool
- spawnLibreOffice :: IO ()
- killLibreOffice :: IO ()
- guarded :: Alternative f => (a -> Bool) -> a -> f a
Tree building
type ParentList a = [(a, Maybe a)] Source #
readForest :: Ord a => ParentList a -> Forest a Source #
Reads a forest from a given ParentList
, sorting each Node
s children.
Counting monad transformer
type CountingT m = StateT Int m Source #
Simple monad transformer that allows to read an increasing Int
.
runCountingT :: Monad m => CountingT m a -> Int -> m a Source #
Evaluate the given action with counting from the given initial value.
XLSX as data backend
storeAsXlsx :: (DefaultOrdered a, ToNamedRecord a) => FilePath -> [a] -> IO () Source #
Store a list of (CSV-transformable) data to a XLSX file. CAVEAT: round-trips don't work with unsafe text values. Use LiBro.Data.SafeText.
loadFromXlsx :: FromNamedRecord a => FilePath -> IO (Either String [a]) Source #
Load a list of (CSV-transformable) data from a XLSX file. CAVEAT: round-trips don't work with unsafe text values. Use LiBro.Data.SafeText.
Shady LibreOffice handling
libreOfficeIsRunning :: IO Bool Source #
Tries to report if a LibreOffice instance is already running
spawnLibreOffice :: IO () Source #
Starts LibreOffice in the background. This is useful to speed up conversion.
killLibreOffice :: IO () Source #
Kills LibreOffice with SIGKILL, if it is actually running.
See libreOfficeIsRunning
.
Other helper functions
guarded :: Alternative f => (a -> Bool) -> a -> f a Source #
Create an Alternative
value based on a predicate.