Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Miscellaneous utility functions for use throughout Drasil.
Synopsis
- chgsStart :: (HasShortName x, Referable x) => x -> Sentence -> Sentence
- definedIn :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence
- definedIn' :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence -> Sentence
- definedIn'' :: (Referable r, HasShortName r) => r -> Sentence
- definedIn''' :: (HasSymbol q, HasUID q, Referable r, HasShortName r) => q -> r -> Sentence
- eqnWSource :: (Referable r, HasShortName r) => ModelExpr -> r -> Sentence
- fromReplace :: (Referable r, HasShortName r) => r -> UnitalChunk -> Sentence
- fromSource :: (Referable r, HasShortName r) => r -> Sentence
- fromSources :: (Referable r, HasShortName r) => [r] -> Sentence
- fmtU :: MayHaveUnit a => Sentence -> a -> Sentence
- follows :: (Referable r, HasShortName r) => Sentence -> r -> Sentence
- makeListRef :: [a] -> Section -> [Sentence]
- addPercent :: Show a => a -> Sentence
- eqN :: Int -> Sentence
- checkValidStr :: String -> String -> Either String String
- getTandS :: Quantity a => a -> Sentence
- maybeChanged :: Sentence -> Sentence -> Sentence
- maybeExpanded :: Sentence -> Sentence -> Sentence
- maybeWOVerb :: Sentence -> Sentence -> Sentence
- showingCxnBw :: NamedIdea c => c -> Sentence -> Sentence
- substitute :: (Referable r, HasShortName r, DefinesQuantity r) => [r] -> Sentence
- typUncr :: HasUncertainty c => c -> Sentence
- underConsidertn :: ConceptChunk -> Sentence
- unwrap :: Maybe UnitDefn -> Sentence
- fterms :: (NamedIdea c, NamedIdea d) => (NP -> NP -> t) -> c -> d -> t
- bulletFlat :: [Sentence] -> ListType
- bulletNested :: [Sentence] -> [ListType] -> ListType
- itemRefToSent :: String -> Sentence -> Sentence
- makeTMatrix :: Eq a => [Sentence] -> [[a]] -> [a] -> [[Sentence]]
- mkEnumAbbrevList :: Integer -> Sentence -> [Sentence] -> [(Sentence, ItemType)]
- mkTableFromColumns :: [(Sentence, [Sentence])] -> ([Sentence], [[Sentence]])
- noRefs :: [ItemType] -> [(ItemType, Maybe String)]
- refineChain :: NamedIdea c => [(c, Section)] -> Sentence
- sortBySymbol :: HasSymbol a => [a] -> [a]
- sortBySymbolTuple :: HasSymbol a => [(a, b)] -> [(a, b)]
- tAndDOnly :: Concept s => s -> ItemType
- tAndDWAcc :: Concept s => s -> ItemType
- tAndDWSym :: (Concept s, Quantity a) => s -> a -> ItemType
- zipSentList :: [[Sentence]] -> [Sentence] -> [[Sentence]] -> [[Sentence]]
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 #
definedIn' :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence -> Sentence Source #
definedIn'' :: (Referable r, HasShortName r) => r -> Sentence Source #
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.
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
substitute :: (Referable r, HasShortName r, DefinesQuantity r) => [r] -> Sentence Source #
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
".
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
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.
mkTableFromColumns :: [(Sentence, [Sentence])] -> ([Sentence], [[Sentence]]) Source #
Helper for making a table from a columns.
noRefs :: [ItemType] -> [(ItemType, Maybe String)] Source #
Converts lists of simple ItemType
s 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 Sentence
s into Terminologies with Definitions.
Returns of the form: "term - termDefinition
".
tAndDWAcc :: Concept s => s -> ItemType Source #
Helpful combinators for making Sentence
s into Terminologies with Definitions.
Returns of the form: "term (abbreviation) - termDefinition
".
tAndDWSym :: (Concept s, Quantity a) => s -> a -> ItemType Source #
Helpful combinators for making Sentence
s 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"]]