Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Utils.Drasil
Description
Gather Drasil's utility functions and re-export for easy use.
Synopsis
- createDirIfMissing :: Bool -> FilePath -> IO ()
- blank :: Doc
- indent :: Doc -> Doc
- indentList :: [Doc] -> Doc
- filterEmpty :: [Doc] -> [Doc]
- listToDoc :: [String] -> Doc
- type Separator = Doc
- contSep :: Separator
- capitalize :: String -> String
- stringList :: [String] -> String
- atLeast2 :: [a] -> Bool
- replaceAll :: Eq a => [a] -> a -> [a] -> [a]
- subsetOf :: Eq a => [a] -> [a] -> Bool
- nubSort :: Ord a => [a] -> [a]
- weave :: [[a]] -> [a]
- foldle :: (a -> a -> a) -> (a -> a -> a) -> a -> [a] -> a
- foldle1 :: (a -> a -> a) -> (a -> a -> a) -> [a] -> a
- toColumn :: [a] -> [[a]]
- mkTable :: [a -> b] -> [a] -> [[b]]
- invert :: Ord v => Map k [v] -> Map v [k]
- toPlainName :: String -> String
- repUnd :: String -> String
- makeCSV :: [[String]] -> Doc
Directory
From Utils.Drasil.Directory.
createDirIfMissing :: Bool -> FilePath -> IO () Source #
Creates a directory if it does not already exist (optionally with all missing parent directories).
Implementation uses doesPathExist to check if the directory exists rather than createDirectoryIfMissing True, which would create the directory regardless of whether it exists or not, potentially leading to an error that appears in `make debug` logs.
Documents
From Utils.Drasil.Document.
indentList :: [Doc] -> Doc Source #
Indents a list of Docs and combines into one Doc.
Language
From Utils.Drasil.English.
capitalize :: String -> String Source #
String capitalization.
stringList :: [String] -> String Source #
Comma separated list with "and" before final item.
Lists
From Utils.Drasil.Lists. General functions involving lists.
replaceAll :: Eq a => [a] -> a -> [a] -> [a] Source #
Replaces all elements of a target list that belong to a provided "bad" input list.
foldle :: (a -> a -> a) -> (a -> a -> a) -> a -> [a] -> a Source #
Fold helper function that applies f to all but the last element, applies g to last element and the accumulator.
foldle1 :: (a -> a -> a) -> (a -> a -> a) -> [a] -> a Source #
Fold helper function that applies f to all but last element, applies g to last element and accumulator without starting value, does not work for empty list.
mkTable :: [a -> b] -> [a] -> [[b]] Source #
Create a table body (not including header row) by applying the given functions to the column elements of the table rows (in order). The first argument is a list of functions to be applied (one per column). This essentially creates the rows. The second argument is a list of elements apply the functions to.
For example, mkTable [id, *5] [1,2,3]
should produce a table:
| 1 | 5 | | 2 | 10 | | 3 | 15 |
Maps
Strings
toPlainName :: String -> String Source #
Replace occurences of special characters (",~`-=!
#$%^&*+[]\;'/|"<>? ")
with underscores (
"_"@).
TODO: This can probably become a bit more comprehensive, anything other than a-z, A-Z, or 0-9 could probably be replaced.