drasil-lang-0.1.60.0: A framework for code and document generation for scientific software - Language SubPackage
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Drasil.Document.Combinators

Description

Miscellaneous utility functions for use throughout Drasil.

Synopsis

Reference-related Functions

Attach a Reference and a Sentence in different ways.

chgsStart :: (HasShortName x, Referable x) => x -> Sentence -> Sentence Source #

Output is of the form "reference - sentence".

definedIn :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence Source #

Takes a HasSymbol that is also Referable and outputs as a Sentence: "symbol is defined in reference."

definedIn' :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence -> Sentence Source #

Same as definedIn, but allows for additional information to be appended to the Sentence.

definedIn'' :: (Referable r, HasShortName r) => r -> Sentence Source #

Takes a Referable and outputs as a Sentence "defined in reference" (no HasSymbol).

definedIn''' :: (HasSymbol q, HasUID q, Referable r, HasShortName r) => q -> r -> Sentence Source #

Takes a Symbol and its Reference (does not append a period at the end!). Outputs as "symbol is defined in source".

eqnWSource :: (Referable r, HasShortName r) => ModelExpr -> r -> Sentence Source #

Takes an expression and a Referable and outputs as a Sentence "expression (source)".

fromReplace :: (Referable r, HasShortName r) => r -> UnitalChunk -> Sentence Source #

Takes a Referable source and a UnitalChunk and outputs as a Sentence: "From source we can replace symbol:".

fromSource :: (Referable r, HasShortName r) => r -> Sentence Source #

Wraps "from reference" in parentheses.

fromSources :: (Referable r, HasShortName r) => [r] -> Sentence Source #

Similar to fromSource but takes a list of references instead of one.

fmtU :: MayHaveUnit a => Sentence -> a -> Sentence Source #

Takes an amount as a Sentence and appends a unit to it.

follows :: (Referable r, HasShortName r) => Sentence -> r -> Sentence Source #

Appends "following reference" to the end of a Sentence.

makeListRef :: [a] -> Section -> [Sentence] Source #

Takes a list and a Section, then generates a list of that section's reference to match the length of the list.

Sentence-related Functions

See Reference-related Functions as well.

addPercent :: Show a => a -> Sentence Source #

Converts input to a Sentence and appends %.

displayStrConstrntsAsSet :: Quantity a => a -> [String] -> Sentence Source #

Produces a Sentence that displays the constraints in a set {}.

displayDblConstrntsAsSet :: Quantity a => a -> [Double] -> Sentence Source #

Produces a Sentence that displays the constraints in a set {}.

eqN :: Int -> Sentence Source #

Prepends the word Equation to an Int.

checkValidStr :: String -> String -> Either String String Source #

Uses an Either type to check if a String is valid - Left with error message if there is an invalid Char in String, else Right with String.

getTandS :: Quantity a => a -> Sentence Source #

Used when you want to say a term followed by its symbol. ex. "...using the Force F in...".

maybeChanged :: Sentence -> Sentence -> Sentence Source #

Helper functions for making likely change statements. Uses form likelyFrame parameter1 _ parameter2.

maybeExpanded :: Sentence -> Sentence -> Sentence Source #

Helper functions for making likely change statements. Uses form likelyFrame parameter1 _ parameter2.

maybeWOVerb :: Sentence -> Sentence -> Sentence Source #

Helper functions for making likely change statements. Uses form likelyFrame parameter1 _ parameter2.

showingCxnBw :: NamedIdea c => c -> Sentence -> Sentence Source #

Returns the Sentence "(titleize aNamedIdea) Showing the Connections Between contents".

substitute :: (Referable r, HasShortName r, DefinesQuantity r) => [r] -> Sentence Source #

Takes a list of Referables and Symbols and outputs as a Sentence "By substituting symbols, this can be written as:".

typUncr :: HasUncertainty c => c -> Sentence Source #

Extracts the typical uncertainty to be displayed from something that has an uncertainty.

underConsidertn :: ConceptChunk -> Sentence Source #

Returns the Sentence "The chunk under consideration is chunkDefinition".

unwrap :: Maybe UnitDefn -> Sentence Source #

Get a unit symbol if there is one.

fterms :: (NamedIdea c, NamedIdea d) => (NP -> NP -> t) -> c -> d -> t Source #

Apply a binary function to the terms of two named ideas, instead of to the named ideas themselves. Ex. fterms compoundPhrase t1 t2 instead of compoundPhrase (t1 ^. term) (t2 ^. term).

List-related Functions

bulletFlat :: [Sentence] -> ListType Source #

Applies Bullet and Flat to a list.

bulletNested :: [Sentence] -> [ListType] -> ListType Source #

Applies Bullets and headers to a Nested ListType. The first argument is the headers of the Nested lists.

itemRefToSent :: String -> Sentence -> Sentence Source #

Makes Sentences from an item and its reference. Takes the title of reference as a String and a Sentence containing the full reference. Wraps the full reference in parenthesis.

makeTMatrix :: Eq a => [Sentence] -> [[a]] -> [a] -> [[Sentence]] Source #

Makes a traceability matrix from a list of row titles, a list of rows of "checked" columns, and a list of columns.

mkEnumAbbrevList :: Integer -> Sentence -> [Sentence] -> [(Sentence, ItemType)] Source #

Zip helper function enumerates abbreviations and zips it with list of ItemType:

  • s - the number from which the enumeration should start from (Integer),
  • t - the title of the list (Sentence),
  • l - the list to be enumerated ([Sentence]).

mkTableFromColumns :: [(Sentence, [Sentence])] -> ([Sentence], [[Sentence]]) Source #

Helper for making a table from a columns.

noRefs :: [ItemType] -> [(ItemType, Maybe String)] Source #

Converts lists of simple ItemTypes into a list which may be used in Contents but is not directly referable.

refineChain :: NamedIdea c => [(c, Section)] -> Sentence Source #

Create a list in the pattern of "The __ are refined to the __". Note: Order matters!

sortBySymbol :: HasSymbol a => [a] -> [a] Source #

Sorts a list of HasSymbols by Symbol.

sortBySymbolTuple :: HasSymbol a => [(a, b)] -> [(a, b)] Source #

Sorts a tuple list of HasSymbols by first Symbol in the tuple.

tAndDOnly :: Concept s => s -> ItemType Source #

Helpful combinators for making Sentences into Terminologies with Definitions. Returns of the form: "term - termDefinition".

tAndDWAcc :: Concept s => s -> ItemType Source #

Helpful combinators for making Sentences into Terminologies with Definitions. Returns of the form: "term (abbreviation) - termDefinition".

tAndDWSym :: (Concept s, Quantity a) => s -> a -> ItemType Source #

Helpful combinators for making Sentences into Terminologies with Definitions. Returns of the form: "term (symbol) - termDefinition".

zipSentList :: [[Sentence]] -> [Sentence] -> [[Sentence]] -> [[Sentence]] Source #

Distributes a list of Sentences by prepending individual Sentences once to an existing list of Sentences.

For example:

>>> zipSentList [S "Hi", S "Hey", S "Hi"] [[S "Hello"], [S "World"], [S "Hello", S "World"]]
[[S "Hi", S "Hello"], [S "Hey", S "World"], [S "Hi", S "Hello", S "World"]]