module Language.Drasil.Document.Contents (
enumBullet, enumBulletU, enumSimple,
enumSimpleU, mkEnumSimpleD,
lbldExpr, unlbldExpr, unlbldCode,
foldlSP, foldlSP_, foldlSPCol
) where
import Control.Lens ((^.))
import Language.Drasil.Classes (Definition(..))
import Language.Drasil.Document.Core (LabelledContent, RawContent(..),
Contents(UlC), ListTuple, ItemType(Flat), ListType(Simple))
import Language.Drasil.Document.Reference (Reference)
import Language.Drasil.Document.Sections (ulcc, mkParagraph, mkRawLC)
import Language.Drasil.Document.SentenceCombinators (bulletFlat, mkEnumAbbrevList)
import Language.Drasil.Expr.Lang (Expr)
import Language.Drasil.Label.Type (Referable(refAdd))
import Language.Drasil.ModelExpr.Lang (ModelExpr)
import Language.Drasil.Sentence (Sentence(..))
import Language.Drasil.Sentence.Fold (foldlSent_, foldlSent, foldlSentCol)
import Language.Drasil.ShortName (HasShortName(..), getSentSN)
lbldExpr :: ModelExpr -> Reference -> LabelledContent
lbldExpr :: ModelExpr -> Reference -> LabelledContent
lbldExpr ModelExpr
c = RawContent -> Reference -> LabelledContent
mkRawLC (ModelExpr -> RawContent
EqnBlock ModelExpr
c)
unlbldExpr :: ModelExpr -> Contents
unlbldExpr :: ModelExpr -> Contents
unlbldExpr ModelExpr
c = UnlabelledContent -> Contents
UlC (UnlabelledContent -> Contents) -> UnlabelledContent -> Contents
forall a b. (a -> b) -> a -> b
$ RawContent -> UnlabelledContent
ulcc (RawContent -> UnlabelledContent)
-> RawContent -> UnlabelledContent
forall a b. (a -> b) -> a -> b
$ ModelExpr -> RawContent
EqnBlock ModelExpr
c
unlbldCode :: Expr -> Contents
unlbldCode :: Expr -> Contents
unlbldCode Expr
c = UnlabelledContent -> Contents
UlC (UnlabelledContent -> Contents) -> UnlabelledContent -> Contents
forall a b. (a -> b) -> a -> b
$ RawContent -> UnlabelledContent
ulcc (RawContent -> UnlabelledContent)
-> RawContent -> UnlabelledContent
forall a b. (a -> b) -> a -> b
$ Expr -> RawContent
CodeBlock Expr
c
enumBullet :: Reference -> [Sentence] -> LabelledContent
enumBullet :: Reference -> [Sentence] -> LabelledContent
enumBullet Reference
lb [Sentence]
s = RawContent -> Reference -> LabelledContent
mkRawLC (ListType -> RawContent
Enumeration (ListType -> RawContent) -> ListType -> RawContent
forall a b. (a -> b) -> a -> b
$ [Sentence] -> ListType
bulletFlat [Sentence]
s) Reference
lb
enumBulletU :: [Sentence] -> Contents
enumBulletU :: [Sentence] -> Contents
enumBulletU [Sentence]
s = UnlabelledContent -> Contents
UlC (UnlabelledContent -> Contents) -> UnlabelledContent -> Contents
forall a b. (a -> b) -> a -> b
$ RawContent -> UnlabelledContent
ulcc (RawContent -> UnlabelledContent)
-> RawContent -> UnlabelledContent
forall a b. (a -> b) -> a -> b
$ ListType -> RawContent
Enumeration (ListType -> RawContent) -> ListType -> RawContent
forall a b. (a -> b) -> a -> b
$ [Sentence] -> ListType
bulletFlat [Sentence]
s
enumSimple :: Reference -> Integer -> Sentence -> [Sentence] -> LabelledContent
enumSimple :: Reference -> Integer -> Sentence -> [Sentence] -> LabelledContent
enumSimple Reference
lb Integer
s Sentence
t [Sentence]
l = RawContent -> Reference -> LabelledContent
mkRawLC (ListType -> RawContent
Enumeration (ListType -> RawContent) -> ListType -> RawContent
forall a b. (a -> b) -> a -> b
$ [ListTuple] -> ListType
Simple ([ListTuple] -> ListType) -> [ListTuple] -> ListType
forall a b. (a -> b) -> a -> b
$ [(Sentence, ItemType)] -> [ListTuple]
noRefsLT ([(Sentence, ItemType)] -> [ListTuple])
-> [(Sentence, ItemType)] -> [ListTuple]
forall a b. (a -> b) -> a -> b
$ Integer -> Sentence -> [Sentence] -> [(Sentence, ItemType)]
mkEnumAbbrevList Integer
s Sentence
t [Sentence]
l) Reference
lb
enumSimpleU :: Integer -> Sentence -> [Sentence] -> Contents
enumSimpleU :: Integer -> Sentence -> [Sentence] -> Contents
enumSimpleU Integer
s Sentence
t [Sentence]
l = UnlabelledContent -> Contents
UlC (UnlabelledContent -> Contents) -> UnlabelledContent -> Contents
forall a b. (a -> b) -> a -> b
$ RawContent -> UnlabelledContent
ulcc (RawContent -> UnlabelledContent)
-> RawContent -> UnlabelledContent
forall a b. (a -> b) -> a -> b
$ ListType -> RawContent
Enumeration (ListType -> RawContent) -> ListType -> RawContent
forall a b. (a -> b) -> a -> b
$ [ListTuple] -> ListType
Simple ([ListTuple] -> ListType) -> [ListTuple] -> ListType
forall a b. (a -> b) -> a -> b
$ [(Sentence, ItemType)] -> [ListTuple]
noRefsLT ([(Sentence, ItemType)] -> [ListTuple])
-> [(Sentence, ItemType)] -> [ListTuple]
forall a b. (a -> b) -> a -> b
$ Integer -> Sentence -> [Sentence] -> [(Sentence, ItemType)]
mkEnumAbbrevList Integer
s Sentence
t [Sentence]
l
noRefsLT :: [(Sentence, ItemType)] -> [ListTuple]
noRefsLT :: [(Sentence, ItemType)] -> [ListTuple]
noRefsLT [(Sentence, ItemType)]
a = ([Sentence] -> [ItemType] -> [Maybe String] -> [ListTuple])
-> ([Sentence], [ItemType]) -> [Maybe String] -> [ListTuple]
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry [Sentence] -> [ItemType] -> [Maybe String] -> [ListTuple]
forall a b c. [a] -> [b] -> [c] -> [(a, b, c)]
zip3 ([(Sentence, ItemType)] -> ([Sentence], [ItemType])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Sentence, ItemType)]
a) ([Maybe String] -> [ListTuple]) -> [Maybe String] -> [ListTuple]
forall a b. (a -> b) -> a -> b
$ Maybe String -> [Maybe String]
forall a. a -> [a]
repeat Maybe String
forall a. Maybe a
Nothing
mkEnumSimpleD :: (Referable c, HasShortName c, Definition c) => [c] -> [Contents]
mkEnumSimpleD :: forall c.
(Referable c, HasShortName c, Definition c) =>
[c] -> [Contents]
mkEnumSimpleD = (c -> ListTuple) -> [c] -> [Contents]
forall a. (a -> ListTuple) -> [a] -> [Contents]
mkEnumSimple ((c -> ListTuple) -> [c] -> [Contents])
-> (c -> ListTuple) -> [c] -> [Contents]
forall a b. (a -> b) -> a -> b
$ (c -> ItemType) -> c -> ListTuple
forall c.
(Referable c, HasShortName c) =>
(c -> ItemType) -> c -> ListTuple
mkListTuple (\c
x -> Sentence -> ItemType
Flat (Sentence -> ItemType) -> Sentence -> ItemType
forall a b. (a -> b) -> a -> b
$ c
x c -> Getting Sentence c Sentence -> Sentence
forall s a. s -> Getting a s a -> a
^. Getting Sentence c Sentence
forall c. Definition c => Lens' c Sentence
Lens' c Sentence
defn)
mkEnumSimple :: (a -> ListTuple) -> [a] -> [Contents]
mkEnumSimple :: forall a. (a -> ListTuple) -> [a] -> [Contents]
mkEnumSimple a -> ListTuple
_ [] = []
mkEnumSimple a -> ListTuple
f [a]
xs = [UnlabelledContent -> Contents
UlC (UnlabelledContent -> Contents) -> UnlabelledContent -> Contents
forall a b. (a -> b) -> a -> b
$ RawContent -> UnlabelledContent
ulcc (RawContent -> UnlabelledContent)
-> RawContent -> UnlabelledContent
forall a b. (a -> b) -> a -> b
$ ListType -> RawContent
Enumeration (ListType -> RawContent) -> ListType -> RawContent
forall a b. (a -> b) -> a -> b
$ [ListTuple] -> ListType
Simple ([ListTuple] -> ListType) -> [ListTuple] -> ListType
forall a b. (a -> b) -> a -> b
$ (a -> ListTuple) -> [a] -> [ListTuple]
forall a b. (a -> b) -> [a] -> [b]
map a -> ListTuple
f [a]
xs]
mkListTuple :: (Referable c, HasShortName c) => (c -> ItemType) -> c -> ListTuple
mkListTuple :: forall c.
(Referable c, HasShortName c) =>
(c -> ItemType) -> c -> ListTuple
mkListTuple c -> ItemType
f c
x = (ShortName -> Sentence
getSentSN (ShortName -> Sentence) -> ShortName -> Sentence
forall a b. (a -> b) -> a -> b
$ c -> ShortName
forall s. HasShortName s => s -> ShortName
shortname c
x, c -> ItemType
f c
x, String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ c -> String
forall s. Referable s => s -> String
refAdd c
x)
foldlSP :: [Sentence] -> Contents
foldlSP :: [Sentence] -> Contents
foldlSP = Sentence -> Contents
mkParagraph (Sentence -> Contents)
-> ([Sentence] -> Sentence) -> [Sentence] -> Contents
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> Sentence
foldlSent
foldlSP_ :: [Sentence] -> Contents
foldlSP_ :: [Sentence] -> Contents
foldlSP_ = Sentence -> Contents
mkParagraph (Sentence -> Contents)
-> ([Sentence] -> Sentence) -> [Sentence] -> Contents
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> Sentence
foldlSent_
foldlSPCol :: [Sentence] -> Contents
foldlSPCol :: [Sentence] -> Contents
foldlSPCol = Sentence -> Contents
mkParagraph (Sentence -> Contents)
-> ([Sentence] -> Sentence) -> [Sentence] -> Contents
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> Sentence
foldlSentCol