drasil-utils-0.1.1.0: A framework for code and document generation for scientific software - Utils SubPackage
Safe HaskellSafe-Inferred
LanguageHaskell2010

Utils.Drasil

Description

Gather Drasil's utility functions and re-export for easy use.

Synopsis

Documents

blank :: Doc Source #

Creates a blank document with no text.

indent :: Doc -> Doc Source #

Indents a document (by 4 spaces).

indentList :: [Doc] -> Doc Source #

Indents a list of Docs and combines into one Doc.

filterEmpty :: [Doc] -> [Doc] Source #

Filter blank Docs from a list.

listToDoc :: [String] -> Doc Source #

Merge a list of Strings into a Doc format:

e.g., `listToDoc [a,b,c,...] ~= a, b, c, ...`

type Separator = Doc Source #

Separates document sections.

Language

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.

atLeast2 :: [a] -> Bool Source #

Check if list has at least 2 elements.

replaceAll :: Eq a => [a] -> a -> [a] -> [a] Source #

Replaces all elements of a target list that belong to a provided "bad" input list.

subsetOf :: Eq a => [a] -> [a] -> Bool Source #

Checks if the first set is a subset of the second.

nubSort :: Ord a => [a] -> [a] Source #

Sort a list, removing all duplicates

weave :: [[a]] -> [a] Source #

Interweaves two lists together [[a,b,c],[d,e,f]] -> [a,d,b,e,c,f].

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.

toColumn :: [a] -> [[a]] Source #

Convert "row" of elements into "column" of elements.

Maps

invert :: Ord v => Map k [v] -> Map v [k] Source #

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.