{-# LANGUAGE GADTs #-}
-- | Lesson plan notebook chapter types.
module Drasil.DocumentLanguage.Notebook.Core where

import Data.Generics.Multiplate (Multiplate(multiplate, mkPlate))
import Language.Drasil

-- * Lesson Chapter Types

type LsnDesc = [LsnChapter]

data LsnChapter = Intro Intro
                | LearnObj LearnObj
                | Review Review
                | CaseProb CaseProb
                | Example Example
                | Smmry Smmry
                | BibSec
                | Apndx Apndx

-- TODO: Work on detail structure of Lesson Plan

-- ** Introduction
newtype Intro = IntrodProg [Contents]

-- ** Learning Objectives
newtype LearnObj = LrnObjProg [Contents]

-- ** Review Chapter
newtype Review = ReviewProg [Contents]

-- ** A Case Problem
newtype CaseProb = CaseProbProg [Contents]

-- ** Examples of the lesson
newtype Example = ExampleProg [Contents]
  
-- ** Summary
newtype Smmry = SmmryProg [Contents]

-- ** Appendix
newtype Apndx = ApndxProg [Contents]

-- * Multiplate Definition and Type

data DLPlate f = DLPlate {
  forall (f :: * -> *). DLPlate f -> LsnChapter -> f LsnChapter
lsnChap :: LsnChapter -> f LsnChapter,
  forall (f :: * -> *). DLPlate f -> Intro -> f Intro
intro :: Intro -> f Intro,
  forall (f :: * -> *). DLPlate f -> LearnObj -> f LearnObj
learnObj :: LearnObj -> f LearnObj,
  forall (f :: * -> *). DLPlate f -> Review -> f Review
review :: Review -> f Review,
  forall (f :: * -> *). DLPlate f -> CaseProb -> f CaseProb
caseProb :: CaseProb -> f CaseProb,
  forall (f :: * -> *). DLPlate f -> Example -> f Example
example :: Example -> f Example,
  forall (f :: * -> *). DLPlate f -> Smmry -> f Smmry
smmry :: Smmry -> f Smmry,
  forall (f :: * -> *). DLPlate f -> Apndx -> f Apndx
apndx :: Apndx -> f Apndx
}

instance Multiplate DLPlate where
  multiplate :: forall (f :: * -> *). Applicative f => DLPlate f -> DLPlate f
multiplate DLPlate f
p = forall (f :: * -> *).
(LsnChapter -> f LsnChapter)
-> (Intro -> f Intro)
-> (LearnObj -> f LearnObj)
-> (Review -> f Review)
-> (CaseProb -> f CaseProb)
-> (Example -> f Example)
-> (Smmry -> f Smmry)
-> (Apndx -> f Apndx)
-> DLPlate f
DLPlate LsnChapter -> f LsnChapter
lc forall {f :: * -> *}. Applicative f => Intro -> f Intro
introd forall {f :: * -> *}. Applicative f => LearnObj -> f LearnObj
lrnObj forall {f :: * -> *}. Applicative f => Review -> f Review
rvw forall {f :: * -> *}. Applicative f => CaseProb -> f CaseProb
csProb forall {f :: * -> *}. Applicative f => Example -> f Example
exmp forall {f :: * -> *}. Applicative f => Smmry -> f Smmry
smry forall {f :: * -> *}. Applicative f => Apndx -> f Apndx
aps where
    lc :: LsnChapter -> f LsnChapter
lc (Intro Intro
x) = Intro -> LsnChapter
Intro forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> Intro -> f Intro
intro DLPlate f
p Intro
x
    lc (LearnObj LearnObj
x) = LearnObj -> LsnChapter
LearnObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> LearnObj -> f LearnObj
learnObj DLPlate f
p LearnObj
x
    lc (Review Review
x) = Review -> LsnChapter
Review forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> Review -> f Review
review DLPlate f
p Review
x
    lc (CaseProb CaseProb
x) = CaseProb -> LsnChapter
CaseProb forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> CaseProb -> f CaseProb
caseProb DLPlate f
p CaseProb
x
    lc (Example Example
x) = Example -> LsnChapter
Example forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> Example -> f Example
example DLPlate f
p Example
x
    lc (Smmry Smmry
x) = Smmry -> LsnChapter
Smmry forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> Smmry -> f Smmry
smmry DLPlate f
p Smmry
x
    lc (Apndx Apndx
x) = Apndx -> LsnChapter
Apndx forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> Apndx -> f Apndx
apndx DLPlate f
p Apndx
x
    lc LsnChapter
BibSec = forall (f :: * -> *) a. Applicative f => a -> f a
pure LsnChapter
BibSec

    introd :: Intro -> f Intro
introd (IntrodProg [Contents]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> Intro
IntrodProg [Contents]
con 
    lrnObj :: LearnObj -> f LearnObj
lrnObj (LrnObjProg [Contents]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> LearnObj
LrnObjProg [Contents]
con 
    rvw :: Review -> f Review
rvw (ReviewProg [Contents]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> Review
ReviewProg [Contents]
con
    csProb :: CaseProb -> f CaseProb
csProb (CaseProbProg [Contents]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> CaseProb
CaseProbProg [Contents]
con 
    exmp :: Example -> f Example
exmp (ExampleProg [Contents]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> Example
ExampleProg [Contents]
con
    smry :: Smmry -> f Smmry
smry (SmmryProg [Contents]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> Smmry
SmmryProg [Contents]
con 
    aps :: Apndx -> f Apndx
aps (ApndxProg [Contents]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> Apndx
ApndxProg [Contents]
con
  mkPlate :: forall (f :: * -> *).
(forall a. Projector DLPlate a -> a -> f a) -> DLPlate f
mkPlate forall a. Projector DLPlate a -> a -> f a
b = forall (f :: * -> *).
(LsnChapter -> f LsnChapter)
-> (Intro -> f Intro)
-> (LearnObj -> f LearnObj)
-> (Review -> f Review)
-> (CaseProb -> f CaseProb)
-> (Example -> f Example)
-> (Smmry -> f Smmry)
-> (Apndx -> f Apndx)
-> DLPlate f
DLPlate (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> LsnChapter -> f LsnChapter
lsnChap) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> Intro -> f Intro
intro) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> LearnObj -> f LearnObj
learnObj) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> Review -> f Review
review) 
    (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> CaseProb -> f CaseProb
caseProb) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> Example -> f Example
example) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> Smmry -> f Smmry
smmry) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> Apndx -> f Apndx
apndx)