{-# LANGUAGE GADTs #-}
module Drasil.DocumentLanguage.Notebook.Core where
import Data.Generics.Multiplate (Multiplate(multiplate, mkPlate))
import Language.Drasil
type NBDesc = [DocSection]
data DocSection = IntrodSec IntrodSec
| BodySec BodySec
| SmmrySec SmmrySec
| BibSec
| ApndxSec ApndxSec
data IntrodSec = IntrodProg [Contents] [IntrodSub]
data IntrodSub where
InPurpose :: [Sentence] -> IntrodSub
newtype BodySec = BodyProg [BodySub]
data BodySub where
Review :: [Contents] -> BodySub
MainIdea :: [Contents] -> [Section] -> BodySub
MethsAndAnls :: [Contents] -> [Section] -> BodySub
Example :: [Contents] -> [Section] -> BodySub
newtype SmmrySec = SmmryProg [Contents]
newtype ApndxSec = ApndxProg [Contents]
data DLPlate f = DLPlate {
DLPlate f -> DocSection -> f DocSection
docSec :: DocSection -> f DocSection,
DLPlate f -> IntrodSec -> f IntrodSec
introdSec :: IntrodSec -> f IntrodSec,
DLPlate f -> IntrodSub -> f IntrodSub
introdSub :: IntrodSub -> f IntrodSub,
DLPlate f -> BodySec -> f BodySec
bodySec :: BodySec -> f BodySec,
DLPlate f -> BodySub -> f BodySub
bodySub :: BodySub -> f BodySub,
DLPlate f -> SmmrySec -> f SmmrySec
smmrySec ::SmmrySec -> f SmmrySec,
DLPlate f -> ApndxSec -> f ApndxSec
apendSec :: ApndxSec -> f ApndxSec
}
instance Multiplate DLPlate where
multiplate :: DLPlate f -> DLPlate f
multiplate p :: DLPlate f
p = (DocSection -> f DocSection)
-> (IntrodSec -> f IntrodSec)
-> (IntrodSub -> f IntrodSub)
-> (BodySec -> f BodySec)
-> (BodySub -> f BodySub)
-> (SmmrySec -> f SmmrySec)
-> (ApndxSec -> f ApndxSec)
-> DLPlate f
forall (f :: * -> *).
(DocSection -> f DocSection)
-> (IntrodSec -> f IntrodSec)
-> (IntrodSub -> f IntrodSub)
-> (BodySec -> f BodySec)
-> (BodySub -> f BodySub)
-> (SmmrySec -> f SmmrySec)
-> (ApndxSec -> f ApndxSec)
-> DLPlate f
DLPlate DocSection -> f DocSection
ds IntrodSec -> f IntrodSec
intro IntrodSub -> f IntrodSub
forall (f :: * -> *). Applicative f => IntrodSub -> f IntrodSub
intro' BodySec -> f BodySec
body BodySub -> f BodySub
forall (f :: * -> *). Applicative f => BodySub -> f BodySub
body' SmmrySec -> f SmmrySec
forall (f :: * -> *). Applicative f => SmmrySec -> f SmmrySec
smry ApndxSec -> f ApndxSec
forall (f :: * -> *). Applicative f => ApndxSec -> f ApndxSec
aps where
ds :: DocSection -> f DocSection
ds (IntrodSec x :: IntrodSec
x) = IntrodSec -> DocSection
IntrodSec (IntrodSec -> DocSection) -> f IntrodSec -> f DocSection
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DLPlate f -> IntrodSec -> f IntrodSec
forall (f :: * -> *). DLPlate f -> IntrodSec -> f IntrodSec
introdSec DLPlate f
p IntrodSec
x
ds (BodySec x :: BodySec
x) = BodySec -> DocSection
BodySec (BodySec -> DocSection) -> f BodySec -> f DocSection
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DLPlate f -> BodySec -> f BodySec
forall (f :: * -> *). DLPlate f -> BodySec -> f BodySec
bodySec DLPlate f
p BodySec
x
ds (SmmrySec x :: SmmrySec
x) = SmmrySec -> DocSection
SmmrySec (SmmrySec -> DocSection) -> f SmmrySec -> f DocSection
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DLPlate f -> SmmrySec -> f SmmrySec
forall (f :: * -> *). DLPlate f -> SmmrySec -> f SmmrySec
smmrySec DLPlate f
p SmmrySec
x
ds (ApndxSec x :: ApndxSec
x) = ApndxSec -> DocSection
ApndxSec (ApndxSec -> DocSection) -> f ApndxSec -> f DocSection
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DLPlate f -> ApndxSec -> f ApndxSec
forall (f :: * -> *). DLPlate f -> ApndxSec -> f ApndxSec
apendSec DLPlate f
p ApndxSec
x
ds BibSec = DocSection -> f DocSection
forall (f :: * -> *) a. Applicative f => a -> f a
pure DocSection
BibSec
intro :: IntrodSec -> f IntrodSec
intro (IntrodProg c :: [Contents]
c progs :: [IntrodSub]
progs) = [Contents] -> [IntrodSub] -> IntrodSec
IntrodProg [Contents]
c ([IntrodSub] -> IntrodSec) -> f [IntrodSub] -> f IntrodSec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
(IntrodSub -> f IntrodSub) -> [IntrodSub] -> f [IntrodSub]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (DLPlate f -> IntrodSub -> f IntrodSub
forall (f :: * -> *). DLPlate f -> IntrodSub -> f IntrodSub
introdSub DLPlate f
p) [IntrodSub]
progs
intro' :: IntrodSub -> f IntrodSub
intro' (InPurpose s :: [Sentence]
s) = IntrodSub -> f IntrodSub
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IntrodSub -> f IntrodSub) -> IntrodSub -> f IntrodSub
forall a b. (a -> b) -> a -> b
$ [Sentence] -> IntrodSub
InPurpose [Sentence]
s
body :: BodySec -> f BodySec
body (BodyProg progs :: [BodySub]
progs) = [BodySub] -> BodySec
BodyProg ([BodySub] -> BodySec) -> f [BodySub] -> f BodySec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (BodySub -> f BodySub) -> [BodySub] -> f [BodySub]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (DLPlate f -> BodySub -> f BodySub
forall (f :: * -> *). DLPlate f -> BodySub -> f BodySub
bodySub DLPlate f
p) [BodySub]
progs
body' :: BodySub -> f BodySub
body' (Review c :: [Contents]
c) = BodySub -> f BodySub
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BodySub -> f BodySub) -> BodySub -> f BodySub
forall a b. (a -> b) -> a -> b
$ [Contents] -> BodySub
Review [Contents]
c
body' (MainIdea c :: [Contents]
c s :: [Section]
s) = BodySub -> f BodySub
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BodySub -> f BodySub) -> BodySub -> f BodySub
forall a b. (a -> b) -> a -> b
$ [Contents] -> [Section] -> BodySub
MainIdea [Contents]
c [Section]
s
body' (MethsAndAnls c :: [Contents]
c s :: [Section]
s) = BodySub -> f BodySub
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BodySub -> f BodySub) -> BodySub -> f BodySub
forall a b. (a -> b) -> a -> b
$ [Contents] -> [Section] -> BodySub
MethsAndAnls [Contents]
c [Section]
s
body' (Example c :: [Contents]
c s :: [Section]
s) = BodySub -> f BodySub
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BodySub -> f BodySub) -> BodySub -> f BodySub
forall a b. (a -> b) -> a -> b
$ [Contents] -> [Section] -> BodySub
Example [Contents]
c [Section]
s
smry :: SmmrySec -> f SmmrySec
smry (SmmryProg con :: [Contents]
con) = SmmrySec -> f SmmrySec
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SmmrySec -> f SmmrySec) -> SmmrySec -> f SmmrySec
forall a b. (a -> b) -> a -> b
$ [Contents] -> SmmrySec
SmmryProg [Contents]
con
aps :: ApndxSec -> f ApndxSec
aps (ApndxProg con :: [Contents]
con) = ApndxSec -> f ApndxSec
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ApndxSec -> f ApndxSec) -> ApndxSec -> f ApndxSec
forall a b. (a -> b) -> a -> b
$ [Contents] -> ApndxSec
ApndxProg [Contents]
con
mkPlate :: (forall a. Projector DLPlate a -> a -> f a) -> DLPlate f
mkPlate b :: forall a. Projector DLPlate a -> a -> f a
b = (DocSection -> f DocSection)
-> (IntrodSec -> f IntrodSec)
-> (IntrodSub -> f IntrodSub)
-> (BodySec -> f BodySec)
-> (BodySub -> f BodySub)
-> (SmmrySec -> f SmmrySec)
-> (ApndxSec -> f ApndxSec)
-> DLPlate f
forall (f :: * -> *).
(DocSection -> f DocSection)
-> (IntrodSec -> f IntrodSec)
-> (IntrodSub -> f IntrodSub)
-> (BodySec -> f BodySec)
-> (BodySub -> f BodySub)
-> (SmmrySec -> f SmmrySec)
-> (ApndxSec -> f ApndxSec)
-> DLPlate f
DLPlate (Projector DLPlate DocSection -> DocSection -> f DocSection
forall a. Projector DLPlate a -> a -> f a
b Projector DLPlate DocSection
docSec) ((forall (f :: * -> *). DLPlate f -> IntrodSec -> f IntrodSec)
-> IntrodSec -> f IntrodSec
forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> IntrodSec -> f IntrodSec
introdSec) ((forall (f :: * -> *). DLPlate f -> IntrodSub -> f IntrodSub)
-> IntrodSub -> f IntrodSub
forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> IntrodSub -> f IntrodSub
introdSub) ((forall (f :: * -> *). DLPlate f -> BodySec -> f BodySec)
-> BodySec -> f BodySec
forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> BodySec -> f BodySec
bodySec)
((forall (f :: * -> *). DLPlate f -> BodySub -> f BodySub)
-> BodySub -> f BodySub
forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> BodySub -> f BodySub
bodySub) ((forall (f :: * -> *). DLPlate f -> SmmrySec -> f SmmrySec)
-> SmmrySec -> f SmmrySec
forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> SmmrySec -> f SmmrySec
smmrySec) ((forall (f :: * -> *). DLPlate f -> ApndxSec -> f ApndxSec)
-> ApndxSec -> f ApndxSec
forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> ApndxSec -> f ApndxSec
apendSec)