drasil-lang-0.1.60.0: A framework for code and document generation for scientific software - Language SubPackage
Safe HaskellNone
LanguageGHC2024

Language.Drasil.Sentence

Description

Contains Sentences and helpers functions.

Synopsis

Types

Sentence

data Sentence where Source #

For writing Sentences via combining smaller elements. Sentences are made up of some known vocabulary of things:

  • units (their visual representation)
  • words (via Strings)
  • special characters
  • accented letters
  • references to specific layout objects

Constructors

Ch :: SentenceStyle -> TermCapitalization -> UID -> Sentence

Ch looks up the term for a given UID and displays the term with a given SentenceStyle and CapitalizationRule. This allows Sentences to hold plural forms of NamedIdeas.

SyCh :: forall t. (IsChunk t, Idea t, HasSpace t, HasSymbol t) => UIDRef t -> Sentence

A branch of Ch dedicated to SymbolStyle only.

Sy :: USymb -> Sentence

Converts a unit symbol into a usable Sentence form.

NP :: NP -> Sentence

Directly embeds a NP

S :: String -> Sentence

Constructor for Strings, used often for descriptions in Chunks.

P :: Symbol -> Sentence

Converts the graphical representation of a symbol into a usable Sentence form.

E :: ModelExpr -> Sentence

Lifts an expression into a Sentence.

Ref :: UID -> Sentence -> RefInfo -> Sentence

Takes a UID to a reference, a display name (Sentence), and any additional reference display information (RefInfo). Resolves the reference later (similar to Ch).

FIXME: Attempting to convert this UID into a UIDRef creates a mess of a cyclic dependency between Reference, ShortName, and this file.

Quote :: Sentence -> Sentence

Adds quotation marks around a Sentence.

Percent :: Sentence

Used for a % symbol.

(:+:) :: Sentence -> Sentence -> Sentence infixr 5

Direct concatenation of two Sentences (no implicit spaces!).

EmptyS :: Sentence

Empty Sentence.

Instances

Instances details
HasChunkRefs Sentence Source # 
Instance details

Defined in Language.Drasil.Sentence

Methods

chunkRefs :: Sentence -> Set UID #

Monoid Sentence Source #

Sentences can be empty or directly concatenated.

Instance details

Defined in Language.Drasil.Sentence

Semigroup Sentence Source #

Sentences can be concatenated.

Instance details

Defined in Language.Drasil.Sentence

Context Types

data SentenceStyle Source #

Used in Ch constructor to determine the state of a term (can record whether something is in plural form, a singular term, or in short form).

data RefInfo Source #

Holds any extra information needed for a Reference, be it an equation, pages, a note, or nothing.

Constructors

None 
Equation [Int] 
Page [Int] 
RefNote String 

Instances

Instances details
HasChunkRefs RefInfo Source # 
Instance details

Defined in Language.Drasil.Sentence

Methods

chunkRefs :: RefInfo -> Set UID #

Generic RefInfo Source # 
Instance details

Defined in Language.Drasil.Sentence

Associated Types

type Rep RefInfo 
Instance details

Defined in Language.Drasil.Sentence

type Rep RefInfo = D1 ('MetaData "RefInfo" "Language.Drasil.Sentence" "drasil-lang-0.1.60.0-1HMwkmtaiHpDlCGzFv9lso" 'False) ((C1 ('MetaCons "None" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Equation" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [Int]))) :+: (C1 ('MetaCons "Page" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [Int])) :+: C1 ('MetaCons "RefNote" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String))))

Methods

from :: RefInfo -> Rep RefInfo x #

to :: Rep RefInfo x -> RefInfo #

type Rep RefInfo Source # 
Instance details

Defined in Language.Drasil.Sentence

type Rep RefInfo = D1 ('MetaData "RefInfo" "Language.Drasil.Sentence" "drasil-lang-0.1.60.0-1HMwkmtaiHpDlCGzFv9lso" 'False) ((C1 ('MetaCons "None" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Equation" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [Int]))) :+: (C1 ('MetaCons "Page" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [Int])) :+: C1 ('MetaCons "RefNote" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String))))

data TermCapitalization Source #

Used in Ch constructor to determine the capitalization of a term. CapF is for capitalizing the first word from the UID of the given term. CapW is for capitalizing all words from the UID of the given term. Mirrors CapFirst and CapWords from CapitalizationRule.

Constructors

CapF 
CapW 
NoCap 

Functions

(+:+) :: Sentence -> Sentence -> Sentence Source #

Helper for concatenating two Sentences with a space between them.

(+:+.) :: Sentence -> Sentence -> Sentence Source #

Helper which concatenates two Sentences using +:+ and appends a period.

(+:) :: Sentence -> Sentence -> Sentence Source #

Helper which concatenates two sentences using +:+ and appends a colon.

(!.) :: Sentence -> Sentence Source #

Helper which appends a period to the end of a Sentence (used often as a post-fix operator).

capSent :: Sentence -> Sentence Source #

Capitalizes a Sentence.

ch :: (IsChunk t, Idea t, HasSpace t, HasSymbol t) => t -> Sentence Source #

Gets a symbol and places it in a Sentence.

eS' :: Express t => t -> Sentence Source #

sC :: Sentence -> Sentence -> Sentence Source #

Helper for concatenating two Sentences with a comma and space between them.

sDash :: Sentence -> Sentence -> Sentence Source #

Helper for concatenating two Sentences with a space-surrounded dash between them.

sParen :: Sentence -> Sentence Source #

Helper for wrapping Sentences in parentheses.

sentencePlural :: UID -> Sentence Source #

Smart constructors for turning a UID into a Sentence.

Gets plural term of UID.

sentenceShort :: UID -> Sentence Source #

Smart constructors for turning a UID into a Sentence.

Gets short form of UID.

sentenceTerm :: UID -> Sentence Source #

Smart constructors for turning a UID into a Sentence.

Gets singular form of UID.

sdep :: Sentence -> Set UID Source #

This is to collect symbolic UIDs that are printed out as a Symbol.

lnames :: Sentence -> Set UID Source #

Generic traverse of all positions that could lead to reference UIDs from Sentences.

lnames' :: [Sentence] -> [UID] Source #

Get reference UIDs from Sentences.